DAX Power Pivot Building a Cash Flow Statement (indirect method) - excel

Here is the current file for this question (download from OneDrive)
I have the following data model:
This is the sample data in each table:
I have this DAX measure to calculate the running sum and get the subtotals for the income statement:
IF (
HASONEVALUE ( DIM_IncStatement[Label] );
CALCULATE (
[Total Value];
ALL ( DIM_IncStatement );
DIM_IncStatement[Code] < VALUES ( DIM_IncStatement[Code] )
)
)
And this one for the operational profit:
=
CALCULATE (
[Subtotal Income Statement];
ALL ( DIM_IncStatement[Level1] );
FILTER ( DIM_IncStatement; DIM_IncStatement[Code] = 9 )
)
Currently the pivot table for the income statement looks like this:
As the cash flow statement if built upon some information from the income statement, I need to get the information and put it in the corresponding rows.
This is the basic structure of the cash flow statement:
QUESTION:
What's the DAX measure to get the "Operational profit", "Cost depreciation", "Expense depreciation", and finally the EBITDA (which is the sum of the previous) in place in the cash flow report?
I'have tried this for the operational profit, but after adding the measure, then pivot table gets empty:
=
CALCULATE (
[Operational profit];
ALL ( DIM_Cash_Flow );
FILTER ( DIM_Cash_Flow; DIM_Cash_Flow[Report code] = "OP" )
)
If anybody can give a hint, I'd really appreciate it...being trying for hours!

Related

I can't get the previous month total in power bi. I am very new to Power Bi. Below is my code

Inventory summary is an excel workbook that was imported. I have a Calendar table and I have Inventory Summary.date linked.
Hardware Inventory Prior Month =
CALCULATE (
SUM ( 'Inventory Summary xls'[Value] ),
FILTER (
'Inventory Summary xls',
'Inventory Summary xls'[Description] = "Hardware"
),
DATEADD ( 'Inventory Summary xls'[Date], -1, MONTH )
)
Your code seems ok. Are you sure you did the modeling correct?
Also please check that your date table is marked as date table. Go to Data View --> Table tools --> Calendars --> Mark as Date Table see picture:
Note: Write your filter argument like this:(Iterate only what you need! not the whole fact table :))
Hardware Inventory Prior Month =
CALCULATE (
SUM ( 'Inventory Summary xls'[Value] ),
FILTER (
ALL ( 'Inventory Summary xls'[Description] ),
'Inventory Summary xls'[Description] = "Hardware"
),
DATEADD ( 'Inventory Summary xls'[Date], -1, MONTH )
)

Power Pivot: Average by group using many-to-many table relationship

I have three tables in Power Pivot. Pupils, Baselines and Reports. The Pupils table connects to the Reports and Baselines tables via a One to Many relationship as shown below.
The Reports table has each pupil listed multiple times for each subject they have a report in. They are also listed multiple times in the Baselines table for each baseline score they have. What I want to accomplish is to create a measure that calculates the average baseline score in each subject. So take all pupils who have a maths report, I want to know the average baseline score in maths.
I tried the following measure:
Av Baseline:=AVERAGEX( CALCULATETABLE( Baselines, Baselines[Type] = "Overall" ), Baselines[Average] )
However the above when used in a pivot table produces the same result for all subjects, so the filter context is not being applied. I keep hearing people using bridge tables, which does add a ton of data and are not very efficient so I hope to avoid those if at all possible.
I have provided some example data with the desired output table, hope that helps?
Could you please test this:
Note: I hope Your Pupils table has a column called [Subject Code] It is not clear from your shared data.
Version - 1
Av Baseline :=
AVERAGEX (
VALUES ( Pupils[Subject Code] ),
CALCULATE (
SUM ( Baselines[Average] ),
CALCULATETABLE ( Baselines, Baselines[Type] = "Overall" )
)
)
Version - 2
Av Baseline =
VAR Combin =
SUMMARIZE (
Baselines,
Baselines[Type],
Pupils[Subject Code],
Baselines[Result]
)
VAR Combinfiltered =
FILTER ( Combin, Baselines[Type] = "Overall" )
VAR Result =
CALCULATE ( AVERAGE ( Baselines[Result] ), Combinfiltered )
RETURN
Result

Excel PowerPivot: Dynamic Rank

I'm trying to create a measure that re-calculates the rank in the power pivot table everytime the user deselects a value or changes the group by row labels. For example, per table below, there are 3 companies rates per quote id with their respective rank in each quote.
Is there a measure that can recalulcate the rank of each company's rate per quote id if the user deselects company B so that power pivot table would look like this:
Also, can the same measure also recalculate the rank by averaging the rank of each quote id if the user removed quote id from the row labels for the power pivot table so that power pivot table would look like this:
Any help appreciated.
Ranking =
IF (
ISFILTERED ( Quotes[Quote] ),
RANKX ( FILTER ( ALLSELECTED ( Quotes[Company] ), [Rate Total] ), [Rate Total],, ASC ),
AVERAGEX (
VALUES ( Quotes[Quote] ),
RANKX ( FILTER ( ALLSELECTED ( Quotes[Company] ), [Rate Total] ), [Rate Total],, ASC )
)
)

Power BI: Combining cells from a column where given a condition

I have to perform a task in power BI (DAX) where i have a list of users and their fields of work.
I have to combine all the fields corresponding to every user and find the highest frequency combination.
Below is how I was planning to do it.
How can i generate the "Expected Result" from the "Sample" file?
Sample:
ID Value
a medicine
b automobile
c banking
d scientist
a banking
a scientist
d banking
Expected Result:
ID Value Combi
a medicine|banking|scientist
b automobile
c banking
d scientist|banking
You can concatenate values from multiple rows and generate a delimited string by using CONCATENATEX() DAX function. Then use ADDCOLUMNS and SUMMARIZE to get the desired result.
Expected Table =
SUMMARIZE (
ADDCOLUMNS (
'Table',
"Combined Value", CONCATENATEX (
FILTER (
SUMMARIZE ( 'Table', 'Table'[ID], [Value] ),
[ID] = EARLIER ( 'Table'[ID] )
),
'Table'[Value],
"|"
)
),
[ID],
[Combined Value]
)
It produces:
Break down the logic
The easiest way in my opinion is create a calculated column in your table to generate the combined value column:
Combined Value =
CONCATENATEX (
FILTER (
SUMMARIZE ( 'Table', 'Table'[ID], [Value] ),
[ID] = EARLIER ( 'Table'[ID] )
),
'Table'[Value],
"|"
)
Then you can create a summarized table based on your table with the previously created calculated column. To create a calculated table go to the Modeling tab and click the New Table icon.
Use this expression:
Resumed Table =
SUMMARIZE ( 'Table', [ID], 'Table'[Combined Value] )
You will get a table like this:
While both methods work just fine, the recommend way to approach this issue is directly from Power Query or from your source.
Let me know if this helps.

Error in dax formula

i'm new to dax. im trying to sum the amount of fatalities per year.
My formula:
= SUMMARIZE (
'TableCrash',
'TableCrash'[Year],
"Fatal", SUM ( 'TableCrash'[Fatalities] )
)
-
example:
SUMMARIZE(<table>, <groupBy_columnName>[, <groupBy_columnName>]…[, <name>, <expression>]…)
Source
There isn't anything wrong with your formula. The problem is how you are using it. Because it returns a table you would usually incorporate this snippet into a larger formula. You can install DAX Studio into Excel to test these snippets. In this case you would execute:
EVALUATE
(
SUMMARIZE (
'TableCrash',
'TableCrash'[Year],
"Fatal", SUM ( 'TableCrash'[Fatalities] )
)
)
But if you have a table that contains Year and Fatalities you don't need any formula to calculate sum of Fatalities. Try to drop both fields into a Power View or pivot table and Fatalities will sum automagically.

Resources