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
vdburg
Resolver I
Resolver I

DAX: Multiply by the product of the previous record

Hi,

I need to get the product of the previous record multiplied by current percentage with DAX.

The dax formula should return the value in the 'Calculation' column. The 'Formula' column shows how the calculation is done in Excel.

 

 BCDE
2PeriodsPercentageCalculationFormula
310,990,990=C3
420,980,970=+C4*D3
530,990,960=+C5*D4


I think that the productx function should be used to do this but I can´t find how. 

This has to be a pretty common calculation, I would appreciate if anyone who dealt with this too could give me a hint.

Thanks,

Robert

1 ACCEPTED SOLUTION

Hi,

I have been testing several ways and this does it:

 

PRODUCTX( filter(ALL(Table1[Periods]) ; Table1[Periods]<= MIN(Table1[Periods])) ; Table1[Percentage_] )

@Mariusz  thanks for you help 

 

best regards

View solution in original post

8 REPLIES 8
Mariusz
Community Champion
Community Champion

Hi @vdburg 

The below will address your issues.

Product x = 
VAR _AllPreviousPeriods = 
FILTER(
    ALL( YourTable ),
    YourTable[Periods] <= MAX( YourTable[Periods] ) 
)
RETURN PRODUCTX( _AllPreviousPeriods, YourTable[Percentage] )

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Hi @Mariusz ,

It did work, however if I add a dimension like 'year' it fails. Do you know of any workaround?

 

Captura_productx.PNG

Mariusz
Community Champion
Community Champion

Hi @vdburg 

You need to replace 'Table1' with Calendar Table / Date Dimension

Like below.

Product x = 
VAR _AllPreviousPeriods = 
FILTER(
    ALL( Calendar ),
    Calendar[Date] <= MAX( Calendar[Date] ) 
)
RETURN PRODUCTX( _AllPreviousPeriods, YourTable[Percentage] )

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski



How would you do this is the % return were a measure from two separate tables sliced down to get the % return? Then continuously multiply the %returns down each row to get a cummulative %return?

Hi @Mariusz ,

I think that unfortunately this approach won´t work because I used a simple example, but I will need to do the calculation with many more dimensions and perform the calculation grouping and degrouping over dimensions.

For example I got this table detailing percentage churn by year and region.

 

Captura_productx2.PNG

But I will also need to agregate the years together:

Captura_productx3.PNG

 

Many thanks

Mariusz
Community Champion
Community Champion

Hi @vdburg 

 

Looking at your example, how would you wont the product to xcalculated, over year and month but with in the region?

 

Many Thanks

Mariusz 

Hi,

I have been testing several ways and this does it:

 

PRODUCTX( filter(ALL(Table1[Periods]) ; Table1[Periods]<= MIN(Table1[Periods])) ; Table1[Percentage_] )

@Mariusz  thanks for you help 

 

best regards

Mariusz
Community Champion
Community Champion

HI @vdburg 

No problem, I'm glad you worked it out

 

Thanks 
Mariusz

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.