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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
shanestocks
Helper I
Helper I

Total Value not Summing Row Values?

Hi all. I have created an "aged stock analysis". One of the columns is "Production Quantity", which simply looks at the earliest date a batch existed, and tries to SUM the total quantity in KG (another column) of that.

 

The calculated column, called "Earliest Batch Date", to retrieve the first date a batch number was found is:

 

CALCULATE(MIN(uk_sap_inventory[Date created]),

ALLEXCEPT(uk_sap_inventory, uk_sap_inventory[Batch], uk_sap_inventory[Visual Material]))

 

I then use that calculated column into a measure called "Production Date" like so:

 

MIN(uk_sap_inventory[Earliest Batch])

 

Finally, I then create a measure called "Production Quantity" using the following:

 

VAR productionDate = [Earliest Batch Date]

RETURN

CALCULATE(

[Quantity (KG)],

uk_sap_inventory[Date created] = productionDate)

 

This works great at the row level, but the total level is wrong. Please see snippit below:

 

shanestocks_0-1724334692591.png

 

I know why it is happening but can't figure out how to rectify it. The total row (material) is taking the lowest batch date and summing that up, leaving out any other dates (in this case 21/08/24). It is therefore showing a value of 30,121, whilst the actual value here is 87,577.

 

Please help! How can I sort this? The row data is absolutely spot on, but the total for that 1 column is completely wrong 😞

 

This is the raw data showing the same batch number as an example:

 

Visual Material Date created Profit Ctr Plnt SLoc Batch Quantity (UOM) Value Stock Age Earliest Batch

10078 - REDACTED21/08/2024

REDACTED

D551LN01202508205904.0082969.51021/08/2024
10078 - REDACTED21/08/2024REDACTEDP501SQ012025082063.00885.35021/08/2024
10078 - REDACTED22/08/2024REDACTEDD551LN01202508206786.0095364.34121/08/2024
10078 - REDACTED22/08/2024REDACTEDP501SQ012025082063.00885.35121/08/2024

 

Many thanks.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi lbendlin ,thanks for the quick reply, I'll add more.

Hi @shanestocks ,

It is recommended that you use the 'ISINSCOPE' function with the IF function

ISINSCOPE function (DAX) - DAX | Microsoft Learn

I assumed some simple data

vzhouwenmsft_0-1724656320091.png

Regarding your question, the row totals are calculated based on how they are calculated in your measure.Suppose I need to get the maximum value, but in the row total I need to calculate the sum of the maximum values, this will happen.

vzhouwenmsft_2-1724656710592.png

 

vzhouwenmsft_1-1724656572535.png

You need to store the maximum value in a virtual table you created, and then use the 'ISINSCOPE' function to perform calculations.

 

Measure 2 = 
VAR _table = SUMMARIZE('Table','Table'[Type],'Table'[group],"Value",[Measure])    //Create a virtual table to store values
VAR _isParent = ISINSCOPE('Table'[group])
VAR _group = SELECTEDVALUE('Table'[group])
RETURN 
IF(_isParent = FALSE(),
SUMX(_table,[Value]),
SUMX(FILTER(_table ,[group] = _group),[Value])
)

 

vzhouwenmsft_3-1724657181966.png

 

Best Regards,
Wenbin Zhou

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi lbendlin ,thanks for the quick reply, I'll add more.

Hi @shanestocks ,

It is recommended that you use the 'ISINSCOPE' function with the IF function

ISINSCOPE function (DAX) - DAX | Microsoft Learn

I assumed some simple data

vzhouwenmsft_0-1724656320091.png

Regarding your question, the row totals are calculated based on how they are calculated in your measure.Suppose I need to get the maximum value, but in the row total I need to calculate the sum of the maximum values, this will happen.

vzhouwenmsft_2-1724656710592.png

 

vzhouwenmsft_1-1724656572535.png

You need to store the maximum value in a virtual table you created, and then use the 'ISINSCOPE' function to perform calculations.

 

Measure 2 = 
VAR _table = SUMMARIZE('Table','Table'[Type],'Table'[group],"Value",[Measure])    //Create a virtual table to store values
VAR _isParent = ISINSCOPE('Table'[group])
VAR _group = SELECTEDVALUE('Table'[group])
RETURN 
IF(_isParent = FALSE(),
SUMX(_table,[Value]),
SUMX(FILTER(_table ,[group] = _group),[Value])
)

 

vzhouwenmsft_3-1724657181966.png

 

Best Regards,
Wenbin Zhou

lbendlin
Super User
Super User

Remember that the total is computed differently than the row level  (in a matrix visual you actually have FOUR different calculations).

 

Your sample data is insufficent.  Provide at least two Visual Materials.  Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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