Powerpivot DAX - I need a way to show a value for Revenue in my profit & loss statement even if there is no Revenue - powerpivot

I am having an issue with a consolidated profit and loss statement using calculated fields. There is a column for GL Group, which is either Revenue or Expense. The calculated field asks "if the value of the row is Revenue then flip the sign of the number", and "if it is expense to leave it as is". And for the net income it takes the sum of both and flips the sign to give you a net profit. My issue is that if there is NO revenue then its BLANK and then expenses, which come through naturally as a positive number, remains a positive number on the net income but should rather be a negative. This is what I am looking to achieve: Revenue should be ZERO if its blank, minus expenses, the result of this will always be a negative number (remember the expenses show as positive). Looking to improve this code:
IF(HASONEVALUE(ActualsBudgetsOB[GL_GROUP]),IF(VALUES(ActualsBudgetsOB[GL_GROUP])="Revenue",CALCULATE(SUM(ActualsBudgetsOB[AMT_ACTUAL])
,FILTER(ActualsBudgetsOB,ActualsBudgetsOB[FISCAL_YR]=[Max Year])
,FILTER(ActualsBudgetsOB,ActualsBudgetsOB[PERIOD]<=[Max Period]))*-1,CALCULATE(SUM(ActualsBudgetsOB[AMT_ACTUAL])
,FILTER(ActualsBudgetsOB,ActualsBudgetsOB[FISCAL_YR]=[Max Year])
,FILTER(ActualsBudgetsOB,ActualsBudgetsOB[PERIOD]<=[Max Period]))),CALCULATE(SUM(ActualsBudgetsOB[AMT_ACTUAL])
,FILTER(ActualsBudgetsOB,ActualsBudgetsOB[FISCAL_YR]=[Max Year])
,FILTER(ActualsBudgetsOB,ActualsBudgetsOB[PERIOD]<=[Max Period]))*-1)

Related

Setting up GST invoice application report differs for item wise sales against total sales

We have set up GST application where I am getting difference between reports like monthly item wise sales report against monthly total sales report.
Please suggest me any changes I need to make for following rules:
We have 3 tables
A. Order master - single line for every order is stored with summarized values
B. Order product details - Each line item stored with respective qty, price etc.
C. Order tax details - line item wise tax details having separate row for CGST, SGST etc.
Here is how I am storing the data:
Tax is applicable on every line item [To generate final invoice all items in order group, we create some of all line items and storing value in Order Master.]
We are rounding 2 decimal value for 3 precision [eg. 4.657 = 4.66, 4.643 = 4.64] as per GST council
Rounding value is stored in Order Master table
For discount there are 2 cases
Percent based discount - Let's say if discount is 10% then from every individual line item 10% discount gets deducted than tax will be applicable for each line item
Flat discount - Let's say for 1000/- Rs order somebody wants to give 80/- Rs. discount than from each line item 8% is deducted and than tax will be applied, off course customer may not pay exact 920/- Rs. amount due to reversal of tax amount.
Now when I am generating following reports:
Monthly item wise sales report [Product wise sales report]
Monthly total sales report [Total sales]
Monthly payment type wise report [Bank, Cheque, Cash]
I am getting difference due to rounding of values. Can anyone suggest me which is the best way to set up rounding formula and up to which decimal point should I go to round the values.
I am using SQL server as backend and .net as front end technology.

Webi SAP BO Sum in block depending on two dimensions

I am trying to sum every line in a table summarizing it by two fields in webi.
I have a table with the following columns:
Risk, Year, AssessedBy, Weight, Value.
I have filtered the table by Year = 2018 and Risk = "01". Thus, I only have the info for that year and that risk.
Each person assessing has a different weight in the final valuation by risk and year. What I have done is divide the assessing person's weight by the total sum of every Weight in the table [ sum(weight) in block ].
The problem is that when I delete the filter, the in block clause makes that the total sum of the weights changes to the total sum of the weights for every year in the table.
I would need something to calculate the total sum for each year and risk.
Just solved it! Just see Sumal Kunir answer: http://www.forumtopics.com/busobj/viewtopic.php?p=971131
=sum([Var_a] for each(Dimension;dimension)) In (Demension)
where var_a is the measure, foreach defines a background to base in and in defines the level at which you want to aggregate.

SSAS Calculated Member - how to do percent of total based on another measure

I am currently trying to create a calculated measure for an SSAS 2008 R2 cube. In a financial cube dealing with accounts receivable data, I have a "Gross Balance" measure, and a "Days Since DOS" measure. The "Days Since DOS" measure is invisible to the user because it is only used in combination with a couple others to gain an average.
I would like the new calculated measure to show the percent of the total gross balance that has a Days Since DOS value > 90.
For example, if the total gross balance were $1000, the total gross balance for records with days since DOS > 90 being $500, the Percent Over 90 Days calculated measure would show 50%.
Would it be possible to do this with my current setup, and if so, how would I go about writing the expression?
I found out that it is in fact possible.
First, create a new named calculation in the DSV using a case statement (for example, call it [Gross Bal Over 90]):
CASE
WHEN [Days Since DOS] > 90 THEN [Gross Balance]
ELSE 0
END
Then, the calculated measure would simply be:
Sum([Gross Bal Over 90])/Sum([Gross Balance])
You can then make [Gross Bal Over 90] invisible to the user, keeping a cleaner look.

"Average" aggregation of sparsely populated percentage values

I have cost center allocation data that is currently fully populated, one record per day, each with one cost center dimension key. The cube has a head count measure (the data is set to "1"), and the aggregate function is set to "LastChild". This means that a head count report will count a person only once in a cost center in any given time period.
Introducing partial allocations - a new measure will have a percentage value for the allocation, allowing for multiple concurrent cost centers where the allocation should add up to 100% (with "day" being the granular level). I am trying to figure out how to configure the aggregation over other time periods. I thought that "Average" should work just fine, i.e. a person who is allocated to a cost center at 50% for half the time period will be reported at 25% for that period.
The problem that I see is that my facts are not populated for days where the allocation to a cost center was 0%. To illustrate:
Employee1 CostCenterA 1/1/2013 50%
Employee1 CostCenterB 1/1/2013 50%
Employee1 CostCenterA 1/2/2013 100%
Employee1 CostCenterA 1/3/2013 100%
... etc with 100% in CostCenterA for all days
The above data on a report by month shows 50% for the allocation to CostCenterB, even though the person was only allocated for one day, and the average percentage on a monthly basis should be 1.6%.
I suppose I could generate the 0%-allocations in the data, but my fact table would explode as a result, so I'd much rather change how the "average" aggregation treats percentage values in facts that are sparsely populated, i.e. the average should be calculated based on the number of granular units in the reporting period (days in the month, in this case 0.5/31), not the number of rows in the fact table (0.5/1). Can this be done in SSAS?
If the measure with the average allocation is off by a factor that is proportional to the "sparseness" of my facts, i.e. the ratio of days in a period and actual fact rows, then it can be corrected as follows:
adjusted average allocation =
(calculated average allocation) * (fact count)/(number of days in period)
I created two new hidden measures, one named [Fact Count] for the fact count (a measure using the AggregateFunction "Count") and a calculated measure named [Days In Period Count] for the number of days, using the expression
COUNT(Descendants([Date].[Calendar].CurrentMember,5),INCLUDEEMPTY)
with [Calendar] being the name of the hierarchy in my Date dimension.
Finally, I added a calculated measure that implements the corrective formula:
[Measures].[Allocative Head Count]/
(
[Measures].[Days In Period Count]/[Measures].[Fact Count]
)
and named it [Adjusted Average Allocation]. This I can now use in reports and it appears to somewhat approximate the average cost center allocation over longer periods.
The formular for [Days In Period Count] btw does not work for the row totals when filters are involved. I opened another question for this.

SSAS custom total for rates (weighting average)

I need to change the total of an interest rate column. I mean, the total in the rate column is summarizing and I need the weighting average instead of the total. for example:
amount..........rate
450000..........8.75
390000..........8
15000...........2
855000(total)...8.29 (weighting average)
I'm trying to do it in the CALCULATIONS tab of the SSAS, but I cannot identify the total level for each group.
Please some ideas, point me to the right direction...
Thanks
JA
I would add a calculation to your source SQL views or DSV to calculate e.g. rate weight = rate * amount. I would then add that as a normal measure, Sum aggregation, hidden once you have finished testing.
Then the SSAS calculation becomes: rate weight / amount (wrapped in the typical Iif function to avoid dividing by zero).
At the leaf levels this returns weight. At any summary level it will return weighted average.