Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
FrankProperty
Frequent Visitor

Compound results up depending on date hierarchy

Hi all,

 

I have a dashboard where the user selects a combination of assets (a list of several hundred options) and the returns over time are shown on a line chart. The user can then drill down across a date hierarchy to see annual, quarterly and monthly returns.

 

The data for the returns calculation is on a monthly basis and the returns are calculated from the underlying data components (ie. numerator and denominator are measures which are calculated depending on the selection and time period) for accuracy rather than a weighted average of the returns.

 

Ideally I want Power BI to calculate the monthly return and then show higher hierarchy levels as a compound of the monthly. The steps would therefore be as follows:

  1. User selects which assets they want using a slicer
  2. Power BI calculates the monthly returns
  3. Power BI then calculates the compounded returns to display at quarterly/annual level.

My first thought was to put the calculated monthly returns into a table and then compound and display those results in the chart but I don't think the tables are that clever in Power BI (I could be mistaken). Is there a clever way to do the above in DAX?

 

Dataset is sensitive but I can whip together a really simple example if it helps.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

// hidden measures:
[_NetValueEnd] =
	SUM( 'Forecast returns FINAL'[Net Value END] )
[_NetOperatingIncome] =
	SUM( 'Forecast returns FINAL'[ Net Operating Income] )
[_NetValueStart] =
	SUM( 'Forecast returns FINAL'[Net Value START] )
[_TotalLeasingCapitalCost] =
	SUM( 'Forecast returns FINAL'[ Total Leasing & Capital Costs (in period)] )


[TPR] =
var __rawFormula =
	PRODUCTX(
	
		GENERATESERIES( 0, 11, 1 ),
		
		var __monthsBack = [Value]
		RETURN
		CALCULATE(
		    DIVIDE(
		        [_NetValueEnd] + [_NetOperatingIncome],
		    	[_NetValueStart] - [_TotalLeasingCapitalCost]
		    ),
		    DATEADD(
		    	// Dates must be marked as the Date table
		        Dates[Date],
		        -(__monthsBack),
		        MONTH
		    )
		)
	)
var __finalFormula = __rawFormula - 1
return
	IF( __finalFormula <> -1, __finalFormula )

View solution in original post

10 REPLIES 10

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors