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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Kitty-SD
Frequent Visitor

Calculating sum with duplicated rows

I have a table that is in the general structure of the table below - each booking has multiple itinerary lines. My problem is that I need the pax calculation to work, regardless of the filters I apply to the page.

KittySD_3-1706031202755.png

I originally was using the Countrows1 custom column which counted how many times the booking appears, so in this instance the pax would be the sum of pax divided by the countrows (8 / 4 = 2). 

 

Countrows1 = CALCULATE(COUNT(Bookings,BookId),ALLEXCEPT(Bookings,BookId))

Pax1 = SUMX(Bookings, Pax / Countrows1)

 

The problem is that this doesn't work when I need to filter by country. So in this instance, if I filtered to Mozambique, it shows 0.5 pax (2 / 4 = 1.5). 

 

I then tried adding another column, Countrows2, so that it counts the number of rows per booking per country. 

 

Countrows2 = CALCULATE(COUNTROWS(Bookings),FILTER(Bookings,[BookId] = EARLIEST(Bookings[BookId])),FILTER(Bookings,[Country]=EARLIEST(Bookings,[Country])))

Pax2 = SUMX(Bookings, Pax / Countrows2)

 

The problem here is that it works as long as you filter the country to either Mozambique or Zimbabwe, but if you don't apply that filter, the total pax is 4.

 

Is there a way of calculating the pax so that it calculates correctly & duplicates / deduplicates when needed, whether or not I apply a country filter to the report?

 

Thanks!

1 ACCEPTED SOLUTION

Hi, thanks so much for your help, but that wasn't quite what I was looking for. 

I actually ended up finding the solution here (using the SUMMARIZE function): Solved: Re: Calculate sum without considering the duplicat... - Microsoft Fabric Community

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@Kitty-SD Having a bit of trouble following this but looks like a measure totals issue. First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi, thanks so much for your help, but that wasn't quite what I was looking for. 

I actually ended up finding the solution here (using the SUMMARIZE function): Solved: Re: Calculate sum without considering the duplicat... - Microsoft Fabric Community

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.