Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Dear All,
I have a text-based column consisting of different categories of calls in my table. I want to calculate the percentage of each category in this column.
I've tried using distinct count and regular count, but the results are not accurate.
Solved! Go to Solution.
Cout = COUNTROWS('Table')
Count All = COUNTROWS('ALL('Table')
Count Per = DIVIDE([Count],[Count All])
Hi @naseem_1973 ,
Hope this works for you.
Okey, I have just realized why!!!
You are using a var as the name of the function. Var is used to store values (https://learn.microsoft.com/en-us/dax/var-dax). Take a look at my code, the name is % of communications. I will paste it again:
% of communications =
var allValues= CALCULATE([Total communications],ALLSELECTED(MyTable[Communication Method]))
return DIVIDE([Total communications],allValues,0)
BTW, variables are really useful in Power BI to improve readability and performance sometimes (https://learn.microsoft.com/en-us/dax/best-practices/dax-variables).
Hi @naseem_1973 ,
Hope this works for you.
Cout = COUNTROWS('Table')
Count All = COUNTROWS('ALL('Table')
Count Per = DIVIDE([Count],[Count All])
Hi @naseem_1973
Try this:
Total communications = COUNTROWS(MyTable)
% of communications =
var allValues= CALCULATE([Total communications],ALL(MyTable))
return DIVIDE([Total communications],allValues,0)
If you want to be able to filter and keep being 100%, use this:
% of communications =
var allValues= CALCULATE([Total communications],ALLSELECTED(MyTable[Communication Method]))
return DIVIDE([Total communications],allValues,0)
Sir , its showin error
Hi @naseem_1973
I don't know why, because for me it's working perfectly. If you select some of the values:
If there's nothing selected:
In fact, my solution also considers the possibility of catching errors while dividing
Please check where I doing mistake.
Okey, I have just realized why!!!
You are using a var as the name of the function. Var is used to store values (https://learn.microsoft.com/en-us/dax/var-dax). Take a look at my code, the name is % of communications. I will paste it again:
% of communications =
var allValues= CALCULATE([Total communications],ALLSELECTED(MyTable[Communication Method]))
return DIVIDE([Total communications],allValues,0)
BTW, variables are really useful in Power BI to improve readability and performance sometimes (https://learn.microsoft.com/en-us/dax/best-practices/dax-variables).
Thanks,
its working
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
86 | |
69 | |
66 | |
51 | |
32 |
User | Count |
---|---|
114 | |
99 | |
75 | |
65 | |
40 |