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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Patelnitya
Frequent Visitor

Incorrect Row and Column Totals

Hello, 

 

I am having some trouble with the following situation. 

 

I have two tables that i am pulling data from. One table is from SQL from my erp system and the other one is from an excel file. 

I have done a merge query of the excel file onto the sql table. Works well. 

 

The SQL table contains the fields called Item code and Qty of Goods on Hand. The excel file contains the field for cost of item.

 

The problem i am having is that Qty of Goods on Hand (StkItem[Qty_On_Hand]) has a default summarization property of Average. I added a DAX calculated column formula as:

 

Cost of Good on Hand = StkItem[Qty_On_Hand]*StkItem[NewColumn.Cost]

 

StkItem[NewColumn.Cost] has a default summarization property of SUM

 

I am getting the row totals correct for Cost of Goods on Hand but the column total is wrong. What is the solution to this problem?

 

Any assistance is appreciable 

 

Thanks,

Nitya

 

1 ACCEPTED SOLUTION
BhaveshPatel
Community Champion
Community Champion

Hi Nitya

 

You can use SUMX function to solve your problem. It is called the iterator function in PBI and iterates through each row of the table and perform the calculation accordingly. 

Create a measure like this 

Cost of Goods on Hand(measure):=
SUMX (
    StkItem,
    StkItem[Qty_On_Hand]*StkItem[NewColumn.Cost])

 

Thanks & Regards,

Bhavesh

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

View solution in original post

1 REPLY 1
BhaveshPatel
Community Champion
Community Champion

Hi Nitya

 

You can use SUMX function to solve your problem. It is called the iterator function in PBI and iterates through each row of the table and perform the calculation accordingly. 

Create a measure like this 

Cost of Goods on Hand(measure):=
SUMX (
    StkItem,
    StkItem[Qty_On_Hand]*StkItem[NewColumn.Cost])

 

Thanks & Regards,

Bhavesh

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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