Forum Discussion
Data modelling suggestions
- 1 year ago
Hi vibhoryadav23 - you can write measures to dynamically calculate the percentage of each error while considering the applied filters.
create total count of Errors
Total Errors =
CALCULATE(
COUNT('Table'[Error]),
ALL('Table'[Error]) -- Ensures all errors are considered, even if some are filtered
)create percentage of Each Error
Error % =
VAR CurrentErrorCount =
COUNT('Table'[Error])
RETURN
DIVIDE(CurrentErrorCount, [Total Errors], 0) * 100Create a measure that applies the selected scenario dynamically
Scenario Filter =
SWITCH(
SELECTEDVALUE('Scenario Table'[Scenario]),
"A", 1, -- No filter applied
"B", IF('Table'[TNr] = 1, 1, 0),
"C", IF('Table'[TNr] = 2 && 'Table'[RT] = 1, 1, 0),
"D", IF('Table'[TNr] >= 2 && 'Table'[RT] = 1, 1, 0),
1 -- Default to no filter
)To exclude "OK" values from the chart while keeping them in calculations
Error % for Chart =
IF(
MAX('Table'[Error]) = "OK",
BLANK(), -- Exclude "OK" from the chart
[Error %] -- Show percentage for other errors
)Use a bar chart to display the percentages for each error.
Set the Error field on the X-axis.
Use the Error % for Chart measure as the Y-axis value.
Add a slicer for the Scenario Table so users can select the desired scenario.Add any other slicers (e.g., for Date, ID, etc.) to allow users to filter the data.
Hope this works. please try
Hi vibhoryadav23 - I hope this works as per your description
Then create a dynamically applies the condition based on the selected scenario. Here’s an updated version of the measure
Scenario Filter =
SWITCH(
SELECTEDVALUE('Scenario Table'[Scenario]),
"A", 1, -- No filter
"B", IF(SELECTEDVALUE('Table'[TNr]) = 1, 1, 0),
"C", IF(SELECTEDVALUE('Table'[TNr]) = 2 && SELECTEDVALUE('Table'[RT]) = 1, 1, 0),
"D", IF(SELECTEDVALUE('Table'[TNr]) >= 2 && SELECTEDVALUE('Table'[RT]) = 1, 1, 0),
1 -- Default: No filter
)
Sorry but still doesnt work. Same result. Its not doing anything to the data at all