Forum Discussion
P&L - Paths
- 1 year ago
Hi MStark,
Thank you for reaching out to Microsoft Fabric Community.
Thank you for sharing all the details. Here are the steps to build your P&L with correct subtotals and PPD logic. Please follow below steps:
- Create calculated columns for hierarchy levels like below:
Level 1 = PATHITEM('Path'[Path], 1, TEXT)
Level 2 = PATHITEM('Path'[Path], 2, TEXT)
Level 3 = PATHITEM('Path'[Path], 3, TEXT)
Level 4 = PATHITEM('Path'[Path], 4, TEXT)
Level 5 = PATHITEM('Path'[Path], 5, TEXT)
Level 6 = PATHITEM('Path'[Path], 6, TEXT)
- Create measure for Total Census like below:
TotalCensus = CALCULATE(SUM('Data'[Amount]), 'Path'[Level 1] = "Census")
- Create measure for Matching Census like below:
MatchingCensus = VAR ThisLevel2 = SELECTEDVALUE('Path'[Level 2])
RETURN
CALCULATE(
SUM('Data'[Amount]),
'Path'[Level 1] = "Census",
'Path'[Level 2] = ThisLevel2
)
- Create Custom Amount measure for subtotals:
Custom Amount =
VAR Level1 = SELECTEDVALUE('Path'[Level 1])
VAR Level2 = SELECTEDVALUE('Path'[Level 2])
VAR Amount = SUM('Data'[Amount])
VAR RB = CALCULATE(SUM('Data'[Amount]),
'Path'[Level 2] IN { "Revenue Current", "Revenue Adjustments" }
)VAR Rev = CALCULATE(SUM('Data'[Amount]), 'Path'[Level 1] = "Revenue")
VAR OpDeps = {
"Nursing and Medical",
"Social Services",
"Therapy and Ancillary",
"Recreation",
"Food and Nutrition"
}
VAR OperatingExp = CALCULATE(SUM('Data'[Amount]),
'Path'[Level 2] IN OpDeps, REMOVEFILTERS('Path'))VAR MgmtExp = CALCULATE(SUM('Data'[Amount]),
'Path'[Level 1] = "Management Expenses", REMOVEFILTERS('Path'))
RETURN
SWITCH(
TRUE(),
Level2 = "Total R&B Revenue", RB,
Level1 = "EBITDAR", Rev + OperatingExp + MgmtExp,
Amount
)
- Create PPD measure like below, this calculates per patient day using the correct base depending on the row:
PPD =
VAR Level1 = SELECTEDVALUE('Path'[Level 1])
VAR Level2 = SELECTEDVALUE('Path'[Level 2])
VAR Amount = [Custom Amount]
VAR TotalCensus = [TotalCensus]
VAR MatchingCensus = [MatchingCensus]
VAR DaysInMonth = 28
RETURN
SWITCH(
TRUE(),
Level1 = "Census", DIVIDE(Amount, DaysInMonth),
Level1 = "Revenue" && Level2 = "Revenue Current", DIVIDE(Amount, MatchingCensus),
DIVIDE(Amount, TotalCensus)
)
In the Matrix visual, add Level 1 to Level 6 as Rows, add Custom Amount and PPD as Values and use slicers for dates or any filters if needed.
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thanks and regards,
Anjan Kumar Chippa
- Create calculated columns for hierarchy levels like below:
- 1 year ago
v-achippa Thanks for your help with this! What worked was doing the following
---Census = CALCULATE(SUM(Data[Amount]),TREATAS({"Census"},'Path'[Level 1]),REMOVEFILTERS('Path'))---DaysInMonth = DAY(EOMONTH(MAX('All Dates'[Date]), 0))---MatchingCensus =VAR SelectedLevel3 = LOWER(TRIM(SELECTEDVALUE('Path'[Level 3])))RETURNIF( NOT ISBLANK(SelectedLevel3), CALCULATE(SUM('Data'[Amount]), FILTER( ALL('Path'), 'Path'[Level 1] = "Census" && LOWER(TRIM(SUBSTITUTE('Path'[Level 2], " Census", ""))) = SelectedLevel3 )))---Path P&L AMNT =VAR Level1 = SELECTEDVALUE('Path'[Level 1])VAR Level2 = SELECTEDVALUE('Path'[Level 2])VAR OperatingDeps = {"Nursing and Medical","Social Services","Therapy and Ancillary","Recreation","Food and Nutrition",}Var Census=CALCULATE(SUM(Data[Amount]),TREATAS({"Census"},'Path'[Level 1]))Var RB=CALCULATE(SUM(Data[Amount]),TREATAS({"Revenue Current","Revenue Adjustments"},'Path'[Level 2]),REMOVEFILTERS('Path'))Var Rev=CALCULATE(SUM(Data[Amount]),TREATAS({"Revenue"},'Path'[Level 1]),REMOVEFILTERS('Path'))Var OperatingExp=CALCULATE(SUM(Data[Amount]),TREATAS(OperatingDeps,'Path'[Level 2]),REMOVEFILTERS('Path'))VAR ManagementExp=CALCULATE(SUM(Data[Amount]),TREATAS({"Management Expenses"},'Path'[Level 1]),REMOVEFILTERS('Path'))RETURNSWITCH(TRUE(),Level2="Total R&B Revenue",RB,Level1="EBITDAR", Rev+OperatingExp+ManagementExp,SUM(Data[Amount]))---Path P&L PPD =VAR Level1 = SELECTEDVALUE('Path'[Level 1])VAR Level2 = SELECTEDVALUE('Path'[Level 2])VAR Amount = [Path P&L AMNT]VAR TotalCensus = [Census]VAR MatchingCensus = [MatchingCensus]VAR DaysInMonth = [DaysInMonth]RETURNSWITCH( TRUE(),Level1 = "Census", DIVIDE(Amount, DaysInMonth),Level1 = "Revenue" && Level2 = "Revenue Current", DIVIDE(Amount, MatchingCensus),TRUE(), DIVIDE(Amount,TotalCensus ))
The issue is that since this is a matrix visual, the total column for Revenue Current is blank by PPD. Since this is not falling into any of the first 2 switch statements should generate amount / total census. Probably an issue since its not real data but a Total line... Any suggestions?
Hi MStark,
Thank you for reaching out to Microsoft Fabric Community.
Thank you for sharing all the details. Here are the steps to build your P&L with correct subtotals and PPD logic. Please follow below steps:
- Create calculated columns for hierarchy levels like below:
Level 1 = PATHITEM('Path'[Path], 1, TEXT)
Level 2 = PATHITEM('Path'[Path], 2, TEXT)
Level 3 = PATHITEM('Path'[Path], 3, TEXT)
Level 4 = PATHITEM('Path'[Path], 4, TEXT)
Level 5 = PATHITEM('Path'[Path], 5, TEXT)
Level 6 = PATHITEM('Path'[Path], 6, TEXT)
- Create measure for Total Census like below:
TotalCensus = CALCULATE(SUM('Data'[Amount]), 'Path'[Level 1] = "Census")
- Create measure for Matching Census like below:
MatchingCensus = VAR ThisLevel2 = SELECTEDVALUE('Path'[Level 2])
RETURN
CALCULATE(
SUM('Data'[Amount]),
'Path'[Level 1] = "Census",
'Path'[Level 2] = ThisLevel2
)
- Create Custom Amount measure for subtotals:
Custom Amount =
VAR Level1 = SELECTEDVALUE('Path'[Level 1])
VAR Level2 = SELECTEDVALUE('Path'[Level 2])
VAR Amount = SUM('Data'[Amount])
VAR RB = CALCULATE(SUM('Data'[Amount]),
'Path'[Level 2] IN { "Revenue Current", "Revenue Adjustments" }
)VAR Rev = CALCULATE(SUM('Data'[Amount]), 'Path'[Level 1] = "Revenue")
VAR OpDeps = {
"Nursing and Medical",
"Social Services",
"Therapy and Ancillary",
"Recreation",
"Food and Nutrition"
}
VAR OperatingExp = CALCULATE(SUM('Data'[Amount]),
'Path'[Level 2] IN OpDeps, REMOVEFILTERS('Path'))VAR MgmtExp = CALCULATE(SUM('Data'[Amount]),
'Path'[Level 1] = "Management Expenses", REMOVEFILTERS('Path'))
RETURN
SWITCH(
TRUE(),
Level2 = "Total R&B Revenue", RB,
Level1 = "EBITDAR", Rev + OperatingExp + MgmtExp,
Amount
)
- Create PPD measure like below, this calculates per patient day using the correct base depending on the row:
PPD =
VAR Level1 = SELECTEDVALUE('Path'[Level 1])
VAR Level2 = SELECTEDVALUE('Path'[Level 2])
VAR Amount = [Custom Amount]
VAR TotalCensus = [TotalCensus]
VAR MatchingCensus = [MatchingCensus]
VAR DaysInMonth = 28
RETURN
SWITCH(
TRUE(),
Level1 = "Census", DIVIDE(Amount, DaysInMonth),
Level1 = "Revenue" && Level2 = "Revenue Current", DIVIDE(Amount, MatchingCensus),
DIVIDE(Amount, TotalCensus)
)
In the Matrix visual, add Level 1 to Level 6 as Rows, add Custom Amount and PPD as Values and use slicers for dates or any filters if needed.
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thanks and regards,
Anjan Kumar Chippa
v-achippa Thanks for your help with this! What worked was doing the following
The issue is that since this is a matrix visual, the total column for Revenue Current is blank by PPD. Since this is not falling into any of the first 2 switch statements should generate amount / total census. Probably an issue since its not real data but a Total line... Any suggestions?
- MStark1 year agoHelper III
Actually figured it out. Updated the Matching Census to include a full census fallback
---MatchingCensus =VAR SelectedLevel3 = LOWER(TRIM(SELECTEDVALUE('Path'[Level 3])))
VAR TotalCensus=[Census]RETURNIF( NOT ISBLANK(SelectedLevel3), CALCULATE(SUM('Data'[Amount]), FILTER( ALL('Path'), 'Path'[Level 1] = "Census" && LOWER(TRIM(SUBSTITUTE('Path'[Level 2], " Census", ""))) = SelectedLevel3 )),TotalCensus)