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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Measure returning Incorrect Totals

I am trying to calculate sales for a particular product class. I am using the below measure:

 

SumSales = SUMX(FILTER(DimProduct,DimProduct[Class]="L"),SUM(FactInternetSales[SalesAmount]))

 

 which is giving me a value of 3787269361.4703 (which is incorrect). However, I tried the below:

 

TotalSales = SUM(FactInternetSales[SalesAmount]) 

SumC = SUMX(filter(DimProduct,DimProduct[Class]="L"),[TotalSales]) 

 

which is giving me a value of 2133761.2238 (this is the correct one).

 

Can you anyone please explain me why the previous dax is not showing the correct total.

As per my knowledge, both DAX are same.

 

What am I missing?

Thanks in advance.

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , You can use calculate

refer: https://exceleratorbi.com.au/double-calculate-solves-sumx-problem/

 

SumSales = SUMX(FILTER(DimProduct,DimProduct[Class]="L"),calculate(SUM(FactInternetSales[SalesAmount])))

 

 

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

View solution in original post

danextian
Super User
Super User

Hi @Anonymous ,

 

In your first formula, what happens is that the total sales amount of rows where Class = L is multipled by the number of rows in table DimProduct wherein the value of Class column is L.  For example if the expected total value is 2133761.2238 and there are 1775 rows with Class L in DimProduct, the total then becomes 2133761.2238 * 1775

You may wrap your aggregation in CALCULATE as what @amitchandak has suggested or, alternatively, create a virtual table with SUMMARIZE.

SUMC =
SUMX (
    SUMMARIZE (
        DimProduct,
        DimProduct[Class],
        "value", IF ( DimProduct[Class] = "L", SUM ( FactInternetSales[SalesAmount] ) )
    ),
    [value]
)

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

3 REPLIES 3
danextian
Super User
Super User

Hi @Anonymous ,

 

In your first formula, what happens is that the total sales amount of rows where Class = L is multipled by the number of rows in table DimProduct wherein the value of Class column is L.  For example if the expected total value is 2133761.2238 and there are 1775 rows with Class L in DimProduct, the total then becomes 2133761.2238 * 1775

You may wrap your aggregation in CALCULATE as what @amitchandak has suggested or, alternatively, create a virtual table with SUMMARIZE.

SUMC =
SUMX (
    SUMMARIZE (
        DimProduct,
        DimProduct[Class],
        "value", IF ( DimProduct[Class] = "L", SUM ( FactInternetSales[SalesAmount] ) )
    ),
    [value]
)

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
amitchandak
Super User
Super User

@Anonymous , You can use calculate

refer: https://exceleratorbi.com.au/double-calculate-solves-sumx-problem/

 

SumSales = SUMX(FILTER(DimProduct,DimProduct[Class]="L"),calculate(SUM(FactInternetSales[SalesAmount])))

 

 

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
Anonymous
Not applicable

Thanks for the solution!!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.