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
djbuncle
Helper I
Helper I

Multi-Step Calculation

Hi. The issue I'm faced with is coming up with a calculation which uses 3 other calculations that are sliced on [Months Since Reg] (on columns) however the final result will be a single value.

To explain further;

Pivot [1] is my base [% Split] calculation respective to the [Months Since Reg]

Pivot [2] shows the [Value Per Player] over the [Months Since Reg]

Pivot [3] shows the multiplcation on [% Split] * [Value Per Player] with respct to the [Months Since Reg] to get [Adj Value Per Player]

Then finally I want to calculate my [Expected Value] in green which is the sum of all [Adj Value Per Player]

 

MultiStepCalc.png

So, as you can see it's a multi-step process where I'd need to utilise several table variables to reach my result, however my DAX skills don't extend to such expertise.

Can anyone shed some light on how I may achieve this?

Thanks.

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

[Expected Value] =
	SUMX(
		ALL ( T[Months Since Reg ] ),
		[% Split] * [Value Per Player]
	)

You can try the above... but I think you'll need some adjustments with respect to other filters. I don't have enough information to tell you exactly what the formula should look like.

 

By the way, [Months Since Reg] must be an attribute in a dimension (not in a fact table).

 

Best

D.

View solution in original post

7 REPLIES 7
Stachu
Community Champion
Community Champion

Can you add sample tables (in format that can be copied to PowerBI) from your model with anonymised data? Like this (just copy and paste into the post window).

Column1Column2
A1
B2.5


probably it will be something like this

Measure =
VAR __Summary =
    SUMMARIZECOLUMNS (
        'Table',
        'Table'[Country],
        'Table'[Months Since Reg],
        "Split", [% Split],
        "VPP", [Value Per Player]
    )
RETURN
    SUMX ( __Summary, [Split] * [VPP] )


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

@Stachu, you should never use SUMMARIZECOLUMNS in a measure. The reason being that SUMMARIZECOLUMNS does not honor filtering context introduced by CALCULATE. This function is purely for QUERIES.

Best
Darek
Stachu
Community Champion
Community Champion

@Anonymous 
fair point



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Hey Stachu, thanks for your response - I've only got around to giving it a go now.

The added complexity here is that the 2 values to multiply are actual calculations themselves using other tables so I can't really supply some example data easily, but here's what the calculated values would be.

 

CountryMonthsSinceRegSplitValuePerPlayer
Germany0                   1.00145
Germany1                   0.14317
Germany2                   0.09303
Germany3                   0.07248
Germany4                   0.06265
Germany5                   0.05239
Germany6                   0.04274
Germany7                   0.04242
Germany8                   0.04227
Germany9                   0.03203
Germany10                   0.03202
Germany11                   0.03262
Germany12                   0.02404
Germany13                   0.02363
Germany14                   0.02352
Germany15                   0.02248
Germany16                   0.02219
Germany17                   0.01364
Germany18                   0.01467
Germany19                   0.011,038

 

I ended up using SUMMARIZE instead of SUMMARIZECOLUMNS to get the calculation to work, but now when I view this in Excel it only seems to do the calculation in month 0. Note that when I'm pivoting in Excel I don't want to use the [Months Since Reg] attribute, this is just needed in memory to do the required calculation -> the end result is one value for Germany.

 

Thanks

Anonymous
Not applicable

[Expected Value] =
	SUMX(
		ALL ( T[Months Since Reg ] ),
		[% Split] * [Value Per Player]
	)

You can try the above... but I think you'll need some adjustments with respect to other filters. I don't have enough information to tell you exactly what the formula should look like.

 

By the way, [Months Since Reg] must be an attribute in a dimension (not in a fact table).

 

Best

D.

That did the trick @Anonymous . Much appreciated.

Anonymous
Not applicable

@djbuncle, please do not use SUMMARIZE for calculating with measures. You should follow the ADDCOLUMNS/SUMMARIZE pattern as outlined here:

https://www.sqlbi.com/articles/best-practices-using-summarize-and-addcolumns/

Best
D.

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