Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
naseem_1973
Helper I
Helper I

%age require a text coulmn

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.

 

sample.png

3 ACCEPTED SOLUTIONS
eliasayyy
Memorable Member
Memorable Member

Cout = COUNTROWS('Table')
Count All = COUNTROWS('ALL('Table')
Count Per = DIVIDE([Count],[Count All])

View solution in original post

Prateek97
Resolver III
Resolver III

Hi @naseem_1973 ,

 

Hope this works for you.

 

Measure = COUNT(CTable[Category])/CALCULATE(COUNT(CTable[Category]),ALL(CTable[Category]))

 

Prateek97_0-1692340828457.png

 

View solution in original post

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). 

View solution in original post

8 REPLIES 8
Prateek97
Resolver III
Resolver III

Hi @naseem_1973 ,

 

Hope this works for you.

 

Measure = COUNT(CTable[Category])/CALCULATE(COUNT(CTable[Category]),ALL(CTable[Category]))

 

Prateek97_0-1692340828457.png

 

eliasayyy
Memorable Member
Memorable Member

Cout = COUNTROWS('Table')
Count All = COUNTROWS('ALL('Table')
Count Per = DIVIDE([Count],[Count All])

mlsx4
Memorable Member
Memorable Member

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:

mlsx4_0-1692345428337.png

 

If there's nothing selected:

mlsx4_1-1692345454603.png

 

In fact, my solution also considers the possibility of catching errors while dividing

Please check where I doing mistake.

naseem_1973_0-1692346981651.png

 

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 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.