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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
rolf1994
Helper II
Helper II

Calculated total showing the wrong number in directquery

Hi, I am trying to calculate the following:

 

Measure

DistinctQuantity = CALCULATE(DISTINCTcount([Id]),[IsActive]="Active")

Measure

TotalPrice= DistinctQuantity*sum(Price)
My data looks like this:
        Price       DistinctQuantity   TotalPrice
A 10 1 10
B 0 100 0
C 0 899 0
Total 10 1000 10000
 
 
 
I want mu table to show a total of "10" but instead it shows 10000. I want to add a column with the distinctquantity but I am working in DirectQuery so i cannot use the Calculate function to add a calculated column. How can I fix this?
1 ACCEPTED SOLUTION
v-sihou-msft
Microsoft Employee
Microsoft Employee

@rolf1994

 

In this scenario, you TotalPrice should be eavaluated on each row level, so you should use SUMX() function.

 

Total Price = SUMX(Table3,Table3[Price]*[Total Quantity])

55.PNG

 

 

Regards,

View solution in original post

2 REPLIES 2
v-sihou-msft
Microsoft Employee
Microsoft Employee

@rolf1994

 

In this scenario, you TotalPrice should be eavaluated on each row level, so you should use SUMX() function.

 

Total Price = SUMX(Table3,Table3[Price]*[Total Quantity])

55.PNG

 

 

Regards,

Greg_Deckler
Community Champion
Community Champion

In general, consider that the total line is really the measure evaluated in the context of ALL. You can add a if HASONEFILTER to your measure to calculate it for rows with the alternative being your calculation for your total row. I may have those reversed. It's early.



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...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.