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
FAA9
Frequent Visitor

MEASURE creation from another measure (dax)

I have the data in a format similar to below in excel powerpivot. I have a calculated measure (for stock cover days) which I need to use to calculate another measure and use it as a KPI.

End of weekProd_hier 1Prod_hier 2Prod_hier 3MarketWH-TypeStock Cover (days)
2022-01-08HIER_1AHIER_2AHIER_3ACAUSWH-B25
2022-01-08HIER_1AHIER_2AHIER_3ACAUSWH-A32

KPI: min(WH-B cover days, 49)-min(WH-A days,21) - 28

Target is to achieve 0 KPI

 

How can I create a measure for this KPI while showing the WH-Type, their stock covers and the KPI in the pivot table?

This does not work

VAR WH-A_cov = CALCULATE( [cover days],ALL(table1[WH-Type]),table1[WH-Type] = "WH-A")
VAR WH-B_cov = CALCULATE( [cover days],ALL(table1[WH-Type]),table1[WH-Type] = "WH-B")

RETURN
MIN(WH-B_cov,49)-MIN(WH-A_cov,21)-28

4 REPLIES 4
v-cgao-msft
Community Support
Community Support

Hi @FAA9 ,

//KPI: min(WH-B cover days, 49)-min(WH-A days,21) - 28

//Target is to achieve 0 KPI

 

min(WH-B cover days, 49)-min(WH-A days,21) - 28

=min(25,49)-min(32,21)-28
=25-21-28

=-24

 

Did I misunderstand? If not, try this measure:

Measure = 
VAR WH_A_cov = 
CALCULATE( 
    [cover days],
    FILTER(ALL(table1),
    table1[WH-Type] = "WH-A"
        && table1[End of week] = MAX(table1[End of week])
        && table1[Prod_hier 1] = MAX(table1[Prod_hier 1])
        && table1[Prod_hier 2] = MAX(table1[Prod_hier 2])
        && table1[Prod_hier 3] = MAX(table1[Prod_hier 3])
    )
)
VAR WH_B_cov = 
CALCULATE( 
    [cover days],
    FILTER(ALL(table1),
    table1[WH-Type] = "WH-B"
        && table1[End of week] = MAX(table1[End of week])
        && table1[Prod_hier 1] = MAX(table1[Prod_hier 1])
        && table1[Prod_hier 2] = MAX(table1[Prod_hier 2])
        && table1[Prod_hier 3] = MAX(table1[Prod_hier 3])
    )
)
VAR _result = 
    MIN(WH_B_cov,49)-MIN(WH_A_cov,21)-28
RETURN
    _result

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Hi,

Thanks @v-cgao-msft 

Thank you for your reply. But this did not work for me. It gave me no result. 

I tries another way, I put dates in the columns, and remove the date filter from the measure; it is giving me -28 only across all columns. 

Hi @FAA9 ,

 

Could you consider providing a sanitized sample file with the expected output?

That would be very helpful.

How to provide sample data in the Power BI Forum

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Hi @v-cgao-msft

I have the data in excel not pbi as I m trying to use dax in power pivot.
Its not letting me attach the excel file 😞

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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

Top Solution Authors
Top Kudoed Authors