Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
Hello,
I would like to do the caluation (Cat) / (Cat + Dog) from a column. But I have two other metrics I don't want to include in the calauation (Mouse & Rabbit), and would would like to filter out.
The [NoPet] measure is a count of all the pets.
Here is my code but it is not working.
Solved! Go to Solution.
Hi,
I am not sure what visualization you want to present the result, but please try something like,
Pets C/D =
DIVIDE (
CALCULATE ( [NoPet], 'Animals'[Pets] IN { "Cat" } ),
CALCULATE ( [NoPet], 'Animals'[Pets] IN { "Cat", "Dog" } )
)
Or,
Pets C/D =
DIVIDE (
CALCULATE ( [NoPet], 'Animals'[Pets] IN { "Cat" } ),
CALCULATE (
[NoPet],
FILTER ( 'Animals', 'Animals'[Pets] <> "Mouse" && 'Animals'[Pets] <> "Rabbit" )
)
)
Hi there!
Can you provice de DAX code of [NoPet].
In the meantime you can try:
Pets C/D =
DIVIDE(
CALCULATE( [NoPet], 'Animals'[Pets] = "Cat" ),
CALCULATE( [NoPet], 'Animals'[Pets] IN { "Cat", "Dog" } )
)
Let me know if that helps!
Hi,
I am not sure what visualization you want to present the result, but please try something like,
Pets C/D =
DIVIDE (
CALCULATE ( [NoPet], 'Animals'[Pets] IN { "Cat" } ),
CALCULATE ( [NoPet], 'Animals'[Pets] IN { "Cat", "Dog" } )
)
Or,
Pets C/D =
DIVIDE (
CALCULATE ( [NoPet], 'Animals'[Pets] IN { "Cat" } ),
CALCULATE (
[NoPet],
FILTER ( 'Animals', 'Animals'[Pets] <> "Mouse" && 'Animals'[Pets] <> "Rabbit" )
)
)
Thank you! The top one works perfectly. I'm using it in a line chart to compare the percentage of cats to dogs over time.
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 8 | |
| 6 | |
| 6 |