The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi Experts,
I have a table of cars and thier Models (Which i have attached ). I am trying to get a count of only the cars that have the "Fault " Value in them. For example, Toyota should completely be excluded from the count in the 'Count of Car Model' since none of its cars have 'Fault' in the 'Car Model" column. So the result should be :Total Count should be "7" and toyota should not show up in the 'Cars" column at all.
Thanks in advance
Solved! Go to Solution.
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
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
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
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
@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
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
21 | |
19 | |
18 | |
15 | |
13 |
User | Count |
---|---|
38 | |
36 | |
22 | |
21 | |
17 |