Forum Discussion
CountIf in PowerBi
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.
- Anonymous4 years agoNot applicable
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 :I used Don't summarize alos.
- Vijay_A_Verma4 years agoMost Valuable Professional
Is $B$2:$B$654 a field name? What about F4 and G4...
- Anonymous4 years agoNot applicable
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
)
)