Forum Discussion
Count Based on specific values in column
- 4 years ago
Hi alawode ,
You can write below measure for getting required output:-
Fault_Car = VAR _max = MAX ( Car_detail[Car] ) VAR result = CALCULATE ( COUNTROWS ( Car_detail ), FILTER ( ALL ( Car_detail ), Car_detail[Car] = _max && Car_detail[Model] = "fault" ) ) RETURN IF ( ISBLANK ( result ), 0, result )Output:-
As you can see total not showing correct so for that you need to write another measure:-
Corrected_total = SUMX ( SUMMARIZE ( Car_detail, Car_detail[Car], Car_detail[Model], "Sum", [Fault_Car] ), [Sum] )Output:-
Note:- Both measure need to create to get a final ouput.
Thank you,
Samarth
Hi alawode ,
You can write below measure for getting required output:-
Fault_Car =
VAR _max =
MAX ( Car_detail[Car] )
VAR result =
CALCULATE (
COUNTROWS ( Car_detail ),
FILTER (
ALL ( Car_detail ),
Car_detail[Car] = _max
&& Car_detail[Model] = "fault"
)
)
RETURN
IF ( ISBLANK ( result ), 0, result )
Output:-
As you can see total not showing correct so for that you need to write another measure:-
Corrected_total =
SUMX (
SUMMARIZE ( Car_detail, Car_detail[Car], Car_detail[Model], "Sum", [Fault_Car] ),
[Sum]
)
Output:-
Note:- Both measure need to create to get a final ouput.
Thank you,
Samarth
- alawode4 years agoHelper I
Samarth_18Thanks a lot for this, it worked well
- alawode4 years agoHelper I
Samarth_18 Thanks for the help, quick question, for some reason the formula is not picking up 20 cars in the bigger table, and all of them have "fault", do you know how to tweak the expression to recify the issue? Thanks