Forum Discussion
DAX expression - How to calculate Weightage average based on a condition
- 2 years ago
To calculate the weighted average of Availability and Performance based on a condition (in this case, "Break") using DAX in Power BI, you can follow these steps:
Create a Measure for Total Time for 'Break' Reason:
TotalTime_Break =
SUMX(
FILTER(
YourTableName,
YourTableName[Reason] = "Break"
),
YourTableName[Total Time]
)
Calculate the Weighted Average for 'Break' Reason:
For the Availability and Performance weighted average, use the following measures:
Using the Measures in Visuals:
If you want to see the weighted averages for each SKU with the 'Break' reason:
- Drag and drop the SKU into a table or matrix visualization.
- Drag the WeightedAvg_Availability and WeightedAvg_Performance measures into the values section of the visualization.
If you want to see the weighted averages for each Date with the 'Break' reason:
- Similarly, drag and drop the Date into a table or matrix visualization.
- Again, drag the WeightedAvg_Availability and WeightedAvg_Performance measures into the values section.
Remember to replace YourTableName with the actual name of your table in Power BI.
These DAX measures should give you the desired weighted averages based on the 'Break' reason either at the SKU level or Date level as per your filters in Power BI.