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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Count repetitions in a row

Hi,

I'm trying to calculating a meaure (to use in a pie chart) to count the number a certain a value (or string) appears in a ROW. I found many examples to calculate columns, but not Rows.

 

Example:

I have this Table called "Stats"

 

crago_0-1602111759203.png

 

I want to count, for each ROW, how many times is appearing the value "High" and how many the value "Low".

Can DAX help me with this? I found a thread here https://community.powerbi.com/t5/Desktop/Count-if-a-value-occurs-in-multiple-columns-per-row/m-p/356... but doesn't seems to work.

 

Thanks everyone!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Not very clear . Try like

 

High =
var _tab = union(all(Table[family management]),all(Table[family information]),all(Table[family parameter]))
return
calculate(countx(filter(_tab,[family management] ="High"),[family management]))

 

Low =
var _tab = union(all(Table[family management]),all(Table[family information]),all(Table[family parameter]))
return
calculate(countx(filter(_tab,[family management] ="High"),[family management]))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Not very clear . Try like

 

High =
var _tab = union(all(Table[family management]),all(Table[family information]),all(Table[family parameter]))
return
calculate(countx(filter(_tab,[family management] ="High"),[family management]))

 

Low =
var _tab = union(all(Table[family management]),all(Table[family information]),all(Table[family parameter]))
return
calculate(countx(filter(_tab,[family management] ="High"),[family management]))

Anonymous
Not applicable

Hi @Anonymous , Can you try creating measure with some DAX as below-

CountHigh = CALCULATE(COUNTROWS(Sheet1), FILTER(Sheet1, Sheet1[Column1]="High"))
CountLow = CALCULATE(COUNTROWS(Sheet1), FILTER(Sheet1, Sheet1[Column1]="Low"))
 

I created a sample data set of 35 Rows with 23 High and 11 as Low. With the help of above 2 Dax formulas i get this output.

Count PieChart.PNG

Hope this helps.

 

Cheers,

-Namish B

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.