Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowDear 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 MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
User | Count |
---|---|
92 | |
65 | |
61 | |
43 | |
40 |