Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello
Apologies if this has been asked before (I had a search but couldn't quite get the existing solutions to fit my query).
I have a column (let's call is Service Level) where the options are 'Good', 'Bad', 'N/A' and I have a column for Unique ID. I have unpivoted my original data set (to calculate a separate formula) so am now left with duplicate unique ID's and duplicate Service Level responses.
What formula do I need to use to calculate the % of 'Good', 'Bad', 'N/A' by unique ID given that the data is unpivoted?
Thanks in advance
Solved! Go to Solution.
Hi. Create a visualization with Service Level and a measure like this:
% of unique =
VAR _num = DISTINCTCOUNT(Table[Unique])
VAR _den = CALCULATE(
DISTINCTCOUNT(Table[Unique])
, ALL(Table)
)
RETURN
DIVIDE ( _num , _den )
After that you can format the measure with % symbol.
Hope that helps,
Happy to help!
@aaronvincentnz ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Unique ID | Service Level |
1054 | Good job |
1054 | Good job |
1054 | Good job |
1054 | Good job |
1054 | Good job |
1054 | Good job |
1054 | Good job |
1074 | Bad job |
1074 | Bad job |
1074 | Bad job |
1074 | Bad job |
1074 | Bad job |
1074 | Bad job |
1156 | Don't know |
1156 | Don't know |
1156 | Don't know |
1156 | Don't know |
1156 | Don't know |
1156 | Don't know |
1156 | Don't know |
1221 | Good job |
1221 | Good job |
1221 | Good job |
1221 | Good job |
1255 | Good job |
1255 | Good job |
1255 | Good job |
1255 | Good job |
1266 | Bad job |
1266 | Bad job |
1266 | Bad job |
1266 | Bad job |
1266 | Bad job |
1266 | Bad job |
1266 | Bad job |
Hi. Create a visualization with Service Level and a measure like this:
% of unique =
VAR _num = DISTINCTCOUNT(Table[Unique])
VAR _den = CALCULATE(
DISTINCTCOUNT(Table[Unique])
, ALL(Table)
)
RETURN
DIVIDE ( _num , _den )
After that you can format the measure with % symbol.
Hope that helps,
Happy to help!
The formula works, but the result is incorrect - I know what the result is meant to be based on checking via a pivot table from the original source data....it looks like I'd get the same result if I use the % of grand total function within the Values field without using any sort of formula...
Hi @aaronvincentnz,
It seems like you share the duplicate sample data with the same status, can you please share some data with raw table structures and expected result to test?
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng
Here's a sample of the data (apologies for the messy formatting)
The 'don't know' is equivalent to N/A from the original info in my question
Data Unpivoted | |
Unique ID | Service Level |
1054 | Good job |
1054 | Good job |
1054 | Good job |
1074 | Bad job |
1074 | Bad job |
1074 | Bad job |
1156 | Don't know |
1156 | Don't know |
1156 | Don't know |
1221 | Good job |
1221 | Good job |
1221 | Good job |
1221 | Good job |
1255 | Good job |
1266 | Bad job |
1266 | Bad job |
Original Data | |
Unique ID | Service Level |
1054 | Good job |
1074 | Bad job |
1156 | Don't know |
1221 | Good job |
1255 | Good job |
1266 | Bad job |
Expected Result | ||
Service Level | Actual Counts | % of Service Level |
Good Job | 3 | 50% |
Bad Job | 2 | 33% |
Don't Know | 1 | 16% |
Total | 6 | 100% |
Here is a measure expression that gets the result shown in a table visual with the Service Level column. Replace Service with your actual table name.
% of Service Level =
VAR countsatlevel =
DISTINCTCOUNT ( Service[Unique ID] )
VAR countsoverall =
CALCULATE (
DISTINCTCOUNT ( Service[Unique ID] ),
ALL ( Service[Service Level] )
)
RETURN
DIVIDE (
countsatlevel,
countsoverall
)
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
That's worked, thanks (sorry for the late reply, been on leave). Just have to work out how to make the legend not display in alphabetical order lol...
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |