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

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.

Reply
titanic123
Helper I
Helper I

CountIf in PowerBi

Hi All, I am stugging doing the same as below excel sheet in Power Bi. Please help me to create the Count IF's using PowerBi DAX. I have data colums : ID,  Count(s), Ratio. Please help me with the COUNTIFS in powerBi  like #of Count(s) =COUNTIFS($B$2:$B$654,F2) and Range of Count(s) =COUNTIFS($C$2:$C$654,J2)

 

titanic123_0-1656823096374.png

 

6 REPLIES 6
Vijay_A_Verma
Super User
Super User

Use below DAX where you would need to replace Table with your table name and Field with your field name (i.e. this is $B$2:$B$654) and F2 with your value for which you want to count.

COUNTIF = 
COUNTROWS(
    FILTER(
        ALL(Table),
        Table[Field] = F2
    )
)   

Hi Vijay, Thanks for yolur quick reply. I have data from past 3 years but COUNTIFS needed only for current year.In the filter if I am adding the year its not working corrcet. Please help me.

I tried my DAX like Below for the Countif formula : =COUNTIFS($B$2:$B$654,">"&F4,$B$2:$B$654,"<="&G4)

 

COUNTIF =
COUNTROWS(
FILTER(
ALL('Query1'),
'Query1'[$B$2:$B$654] > 'Query1'[&F4] && 'Query1'[$B$2:$B$654] <= 'Query1'[&G4] && 'Query1'[Year]=2022
)
)
 
But Resultes are : titanic123_0-1656858203348.png

 I used Don't summarize alos.

 

 

Is $B$2:$B$654 a field name? What about F4 and G4...

My column names in PowerBi are different, I am just representing the column names in Excel.

My DAX ; 

COUNTIF =
COUNTROWS(
FILTER(
ALL('Query1'),
'Query1'[VN_OT] > 'Query1'[Lower Limit] && 'Query1'[VN_OT] <= 'Query1'[Upper Limit] && 'Query1'[VN Year]=2022
)
)

 

Isn't your count correct? I tested your formula and it is giving correct count. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors