Forum Discussion

FAA9's avatar
FAA9
Frequent Visitor
3 years ago

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

  • Anonymous's avatar
    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

    • FAA9's avatar
      FAA9
      Frequent Visitor

      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.