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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
v-xinc-msft
Community Support
Community Support

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

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
v-xinc-msft
Community Support
Community Support

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

 

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.