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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Sreerams26
Frequent Visitor

Subtotal without calculation

I have two tables.  First table has product and warehouse wise price for various dates in current year and second table has the product and warehouse wise quantity as on date.  I had created a measure to pickup the latest date using the below DAX code in the first table - 

Latest Price =
VAR LatestDate =
   CALCULATE(
      MAX('Item price'[Pricecreateddatetime]),
      ALLEXCEPT('Item price', 'Item price'[Unique item])
   )
RETURN
   CALCULATE(
      MAX('Item price'[Price]),
      FILTER(
         'Item price',
         'Item price'[Pricecreateddatetime] = LatestDate
      )
   )
 
Then, calculated the inventory value in the same table using 
Inventory Value = [Latest Price]*SUM('On hand Inventory'[OnHandQuantity]).
 
Finally, I create a matrix table.  The materials are grouped by category.  Hence, the matrix table brings in data by category.  Individual data is perfect however the sub total is not showing the sum of inventory value. rather it is taking the highest price in that group and multiplying with the total qty.  In this eg. total qty in the group is 30 and multiplying with highest value 95.87.  however, the actual total of all inventory value is 2344.20.
 
Sreerams26_0-1681154962355.png

How do I ensure that the total displayed is actually the sum of all items. 

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-zhangti
Community Support
Community Support

Hi, @Sreerams26 

 

I simulated some data to hopefully match your situation. Please mainly look at the method.

[Lastest Price] is a measure.

Measure = SUM('Table'[Physical Inventory])*[Lastest Price]
Inventory Value = IF(HASONEVALUE('Table'[Unique item]),[Measure],SUMX('Table',[Measure]))

vzhangti_0-1681265040607.png

IF(HASONEVALUE()) can control the output of total.
 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

First of all, thanks for the response.  I am not sure if I did it correctly, still I am not getting the right response. Based on your suggestion, I made the necessary changes in the formula. The total in Group ASIA is reconciling howerver, none of the other groups match.  So wondering what could be missing?

 

Sreerams26_1-1681315939935.png

Inv Value Measure = [Latest Price]*SUM('On hand Inventory'[OnHandQuantity])
Inventory Value = if(HASONEVALUE('Item price'[Unique item]),[Inv Value Measure], SUMX('Item price',[Inv Value Measure]))

Hi, @Sreerams26 

 

Sample data:

vzhangti_0-1681365230045.png

The formula does not change.

vzhangti_1-1681365272741.png

If your results are inconsistent with expectations, can you provide more data?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.