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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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

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 @Anonymous 

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. 

Anonymous
Not applicable

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 @Anonymous

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors