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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
maart21
Regular Visitor

The difference between scenarios containing different data

Hi, I really need help as I haven't found an answer despite searching the forums.

I have production forecasts (MPS) for individual products (Product), each row represents one product that is scheduled to be completed in the month specified in the PLAN-FINISH.

I need to build a matrix where, after selecting several scenarios on slicer, the difference between these scenarios will be calculated. If there is no planned production completion for a specific month, it should be treated as 0 so that the difference between the scenarios can be calculated correctly. Just like in the image below:
Przechwytywanie.JPG

 

I am attaching my sample file 
Thank you in advance for any help.

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @maart21 ,

Please try the measure:

Measure = 
    Var _Previous=
        CALCULATE(
            SUM(Arkusz1[Qty]),
            FILTER(
                ALL(Arkusz1),
                [MPS]="B"&
                RIGHT(SELECTEDVALUE(Arkusz1[MPS]),2)-1&&
                [PLAN-FINISH].[Miesiąc]=SELECTEDVALUE(Arkusz1[PLAN-FINISH].[Miesiąc])&&
                [Produkt]=SELECTEDVALUE(Arkusz1[Produkt]
        )
    )
)
RETURN
SUM(Arkusz1[Qty])-_Previous

14.png

Best regards,

Lucy Chen

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

Anonymous
Not applicable

Hi @maart21 ,

Please try this.

Result = 
Var _table=SUMMARIZE(Arkusz1,[MPS],Arkusz1[Produkt],Arkusz1[PLAN-FINISH].[Miesiąc],"Diff",[Measure])
RETURN
SUMX(_table,[Diff])

 4.png

Best regards,

Lucy Chen

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

5 REPLIES 5
Anonymous
Not applicable

Hi @maart21 ,

Please try the measure:

Measure = 
    Var _Previous=
        CALCULATE(
            SUM(Arkusz1[Qty]),
            FILTER(
                ALL(Arkusz1),
                [MPS]="B"&
                RIGHT(SELECTEDVALUE(Arkusz1[MPS]),2)-1&&
                [PLAN-FINISH].[Miesiąc]=SELECTEDVALUE(Arkusz1[PLAN-FINISH].[Miesiąc])&&
                [Produkt]=SELECTEDVALUE(Arkusz1[Produkt]
        )
    )
)
RETURN
SUM(Arkusz1[Qty])-_Previous

14.png

Best regards,

Lucy Chen

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

Thank you v-xinc-msft, 
looks good, but when I add sums to my my matrix,  values are not correct.
Przechwytywanie.JPG

 

Anonymous
Not applicable

Hi @maart21 ,

Please try this.

Result = 
Var _table=SUMMARIZE(Arkusz1,[MPS],Arkusz1[Produkt],Arkusz1[PLAN-FINISH].[Miesiąc],"Diff",[Measure])
RETURN
SUMX(_table,[Diff])

 4.png

Best regards,

Lucy Chen

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

lbendlin
Super User
Super User

To report on things that are not there you need to use disconnected tables and/or crossjoins

 

In your case you need to create a product dimension table and a month dimension table.  Then use measures to show the count for each combination, as well as the delta between the MPS versions.

Hi lbendlin,

thank you for tip, it takes a while but I was able to create measure that works.

Difference = 
VAR CurrentValue =
    CALCULATE(
        SUM(Arkusz1[Qty]),
        TREATAS(VALUES(DimMPS[MPS]), Arkusz1[MPS]),
        TREATAS(VALUES(DimMonths[Date]), Arkusz1[PLAN-FINISH]),
        VALUES(Arkusz1[Produkt])
    )
VAR PreviousMPS =
    CALCULATE(
        MAX(DimMPS[MPS]),
        FILTER(
            ALL(DimMPS),
            DimMPS[MPS] < SELECTEDVALUE(DimMPS[MPS])
        )
    )
VAR PreviousValue =
    CALCULATE(
        SUM(Arkusz1[Qty]),
        TREATAS({PreviousMPS}, Arkusz1[MPS]),
        TREATAS(VALUES(DimMonths[Date]), Arkusz1[PLAN-FINISH]),
        VALUES(Arkusz1[Produkt])
    )
RETURN
IF(
    ISBLANK(CurrentValue) && ISBLANK(PreviousValue),
    0,
    COALESCE(CurrentValue, 0) - COALESCE(PreviousValue, 0)
)




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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