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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
CasperSV
Helper II
Helper II

Power BI Matrix

Hi guys,

 

I have made a Matrix in Power BI, however it should exclude the type Forecast as soon as the type Sales order (named order in report) has the same amount. 

 

Current result:

CasperSV_0-1669119797404.png

 

 

CasperSV_1-1669120051104.png

 

Do you guys know how to edit the measure to get to this result?

Thanks in advance!

 

Download report:

Test Power BI Demand forecast.pbix

 

Best regards,

Casper

1 ACCEPTED SOLUTION

Hi @CasperSV ,

Please replace before measure with below dax formula:

Available per week (Switch) =
VAR _a =
    CALCULATE (
        [Mutations this week],
        FILTER ( ALL ( Lines ), [Type] = "Forecast" )
    )
VAR _b =
    CALCULATE ( [Mutations this week], FILTER ( ALL ( Lines ), [Type] = "Order" ) )
VAR _c =
    IF (
        MAX ( 'Lines'[Type] ) = "Forecast"
            && _a = _b,
        BLANK (),
        [Mutations this week]
    )
RETURN
    SWITCH (
        TRUE (),
        ISINSCOPE ( 'Lines'[Type] ), _c,
        ISINSCOPE ( 'Lines'[Item number] ),
            IF (
                _a = _b,
                [Available quantity per week] - _a,
                [Available quantity per week]
            ),
        BLANK ()
    )

vbinbinyumsft_0-1669282935040.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
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

4 REPLIES 4
CasperSV
Helper II
Helper II

Thank you!

v-binbinyu-msft
Community Support
Community Support

Hi @CasperSV ,

Please try below dax formula and add it to matrix value:

Available per week (Switch) =
VAR _a =
    CALCULATE (
        [Mutations this week],
        FILTER ( ALL ( Lines ), [Type] = "Forecast" )
    )
VAR _b =
    CALCULATE ( [Mutations this week], FILTER ( ALL ( Lines ), [Type] = "Order" ) )
VAR _c =
    IF (
        MAX ( 'Lines'[Type] ) = "Forecast"
            && _a = _b,
        BLANK (),
        [Mutations this week]
    )
RETURN
    SWITCH (
        TRUE (),
        ISINSCOPE ( 'Lines'[Type] ), _c,
        NOT ISINSCOPE ( 'Lines'[Type] ), [Available quantity per week]
    )

vbinbinyumsft_0-1669186631210.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-binbinyu-msft 

 

Thanks a lot for your effort and help!

 

It is almost the solution I need, however the Total in week 47 is still -8.

It should be 0, because the order is replacing the forecast: Inventory (8) - Order (8) = 0.

 

Best regards,

Casper

Hi @CasperSV ,

Please replace before measure with below dax formula:

Available per week (Switch) =
VAR _a =
    CALCULATE (
        [Mutations this week],
        FILTER ( ALL ( Lines ), [Type] = "Forecast" )
    )
VAR _b =
    CALCULATE ( [Mutations this week], FILTER ( ALL ( Lines ), [Type] = "Order" ) )
VAR _c =
    IF (
        MAX ( 'Lines'[Type] ) = "Forecast"
            && _a = _b,
        BLANK (),
        [Mutations this week]
    )
RETURN
    SWITCH (
        TRUE (),
        ISINSCOPE ( 'Lines'[Type] ), _c,
        ISINSCOPE ( 'Lines'[Item number] ),
            IF (
                _a = _b,
                [Available quantity per week] - _a,
                [Available quantity per week]
            ),
        BLANK ()
    )

vbinbinyumsft_0-1669282935040.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors