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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
amestrian
Frequent Visitor

Calculate percentage where numerator and denominator have different filters on the same table

Hi all, 

 

I'm quite new to Power BI and I'm stuck with this issue. 

I have a table similar to the following (had to create a dummy one to post here - hope it's okay)

IDClick dataset
11A
21A
30A
41A
50A
11B
20B
30B
40B
10C
21C
30C
41C
50C

 

The column dataset is to identify the data source. You'll see each ID is repeated for each dataset. 

 

Basically what I'm trying to do is calculate the percentage of clicks in dataset B out of the number of clicks in dataset A. The result should be: 1 / 3 = 33%

Same thing but for dataset C: 2/3 = 66%

 

I've tried a measure like the following: 

 

pc_clicks_b = DIVIDE(CALCULATE(COUNTROWS(Table),

FILTER(Table,Table[clicks]=1),FILTER(Table,Table[dataset]="B")),

CALCULATE(COUNTROWS(Table),FILTER(Table,Table[clicks]=1),FILTER(Table,Table[dataset]="A")))

 

But it's not working. This will be used in a card.

I've tried things in other questions but I haven't seen this case asked before, if it was please direct me to it and apologies for the duplicate. 

Any ideas?

2 REPLIES 2
amitchandak
Super User
Super User

@amestrian , Try one of the two options

 

pc_clicks_b = DIVIDE(CALCULATE(COUNTROWS(Table), FILTER(Table,Table[clicks]=1 && Table[dataset]="B")),
CALCULATE(COUNTROWS(Table),FILTER(Table,Table[clicks]=1 && Table[dataset]="A")))

 

or

 

pc_clicks_b = DIVIDE(CALCULATE(COUNTROWS(Table), FILTER(all(Table),Table[clicks]=1 && Table[dataset]="B")),
CALCULATE(COUNTROWS(Table),FILTER(all(Table),Table[clicks]=1 && Table[dataset]="A")))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak 

 

That seems to have worked. Strangely, however, I had to add a filter that was already in "filters on all pages", specifically to each part of the division... not sure why that happens but it works now. I wonder if it will break somehow later because of that..

 

Also, can you explain why using && it works but using many FILTER() functions it doesn't? It's quite funny

 

Edit: one more question actually, sorry. The number is right for the general casec (without slicers), however I see my slicers won't affect these two cards, not even date slicers. Why is that? 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors