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! Learn more

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