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
Anonymous
Not applicable

Urgent please - Delta on 2 scenarios

Hi, 

 

I have the data in a table called RawData in this format:

ScenarioFunctionMetric
AAA10
AAA20
AAB10
BAA30
BAB40
BAB10

and I will want to retrieve 2 matrix tables displayed like this:

One that is based on a slicer where scenario = A on this format

FunctionSum of scenario ADelta of selected scenarios in selected slicers
AA300
AB10-40

One that is based on a slicer where scenario = B on this format

 Sum of scenario B
AA30
AB50

 

Can you, please, support on this?

Many thanks!

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Sorry I misunderstood your needs before, please try this MEASURE:

Delta of selected scenarios in selected slicers = 
var _a = SUMMARIZE('Table','Table'[Function],"Metric",SUM('Table'[Metric]),"Metric2",CALCULATE(SUM('Table'[Metric]),FILTER(ALL('Table'),[Function]=EARLIER('Table'[Function])&&[Scenario] =SELECTEDVALUE('For slicer'[Scenario]))))
return 
SUMX(_a,[Metric]-[Metric2])

 Output:

vjianbolimsft_0-1675215459121.png

vjianbolimsft_1-1675215470602.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try:

Measure =
IF (
    ISINSCOPE ( 'Table'[Scenario] ),
    SUM ( 'Table'[Metric] ),
    CALCULATE ( SUM ( 'Table'[Metric] ), FILTER ( 'Table', [Scenario] = "A" ) )
        - CALCULATE ( SUM ( 'Table'[Metric] ), FILTER ( 'Table', [Scenario] = "B" ) )
)

Output:

vjianbolimsft_0-1675157328215.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Unfortunately, the user wants what I mentioned in the initial msg, 2 slicers with 2 tables. The intial solution you have provided was doing that, except that the column total for delta was not ok..

Hi @Anonymous ,

 

Sorry I misunderstood your needs before, please try this MEASURE:

Delta of selected scenarios in selected slicers = 
var _a = SUMMARIZE('Table','Table'[Function],"Metric",SUM('Table'[Metric]),"Metric2",CALCULATE(SUM('Table'[Metric]),FILTER(ALL('Table'),[Function]=EARLIER('Table'[Function])&&[Scenario] =SELECTEDVALUE('For slicer'[Scenario]))))
return 
SUMX(_a,[Metric]-[Metric2])

 Output:

vjianbolimsft_0-1675215459121.png

vjianbolimsft_1-1675215470602.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you very much, this is perfect!!

v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try:

First create a new table for slcier:

vjianbolimsft_0-1675143996425.png

Then apply the measure:

Delta of selected scenarios in selected slicers =
SUM ( 'Table'[Metric] )
    - CALCULATE (
        SUM ( 'Table'[Metric] ),
        FILTER (
            ALL ( 'Table' ),
            [Function] = MAX ( 'Table'[Function] )
                && [Scenario] = SELECTEDVALUE ( 'For slicer'[Scenario] )
        )
    )

Create two slicers using 'Table'[Scenario] and 'For slicer'[Scenario] respectively

Final output:

vjianbolimsft_1-1675144153221.png

vjianbolimsft_2-1675144162853.png

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi, 

 

It's working, but the bottom totals are not doing delta. I mean, in your examples,  I should have - 40 and 0 on the bottom tables as grand totals.

 

Thank you!

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.