The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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 week | Prod_hier 1 | Prod_hier 2 | Prod_hier 3 | Market | WH-Type | Stock Cover (days) |
2022-01-08 | HIER_1A | HIER_2A | HIER_3AC | AUS | WH-B | 25 |
2022-01-08 | HIER_1A | HIER_2A | HIER_3AC | AUS | WH-A | 32 |
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
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 😞
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.