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.

Frequent Visitor

## sum of two measure showing incorrect value

Hi All

I have two tables

Table 1 with Stock names and the quantity purchased

Table 2 with Last 1 year Historic prices of each stock

I have a two measure

1. Measure 1 - total quantity which is the sum of all the quantites  of the stock

2. Measure 2 - Last Traded Price = This gives the Last trade price of each stock on the last traded date say 13th Jan 2023

I want to calculate the portfolio value on the Last Traded Date which should be simply the the sumproduct of quantity i have (measure 1) and the Last traded price (measure 2) for each stock

Thanks in Advance

1 ACCEPTED SOLUTION
Impactful Individual

Oh i didnt see your latest reply of thr table please try

• Correct values = if(hasonevalue(table[stockname]),[portfolio measure],sumx(values(table[stockname]),[portfolio measure]))
6 REPLIES 6
Impactful Individual

Hello @baronraghu_3011 can you please share the measures as well as providing a sample of your data would help a lot

Frequent Visitor

HI,

table 1 has two columns

Column 1 - stock name

Column 2 - quantity

Measure 1 - Sum( Table1[quantity])

Table 2 has tow columns

Column 1 - Stock Name

Colume 2 - Date

Column 3 -  Daily Stock Price

I craeted a two refernce Measure for the

1. Last Trading Date = Today()-2

2. Stock Price = Sum (Table 2[Stock Price])

Measure 2 - Last Trading Price = calculate (Stock Price, Filter( Date, Date[Date]= Last Trading Date))

For calculating my total Portfolio Value = Measure 1 ( Total Quantity)* Measure 2 ( Last Trading Price) .

This I understand maynot give correct value as the quantity is multiplied with all the stock prices. So i believe it must be sum product. But hoe to apply has been my concern.

Impactful Individual

I think youcan try a sumx measure

Sumx(values(table[date]),measure1 * measure 2)

Super User

@baronraghu_3011 Hard to say with the information provided but, perhaps this is the classic measure totals problem?

First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Frequent Visitor

Hi,

Thanks for those links. I understand a bit that using Hasonefilter along with SUMX might  turnaround the table the way I want to look but finding it hard to implement.   I have shared  snap of my table below for your refernce. The red circle is my issue which doesnt add up.

Impactful Individual

Oh i didnt see your latest reply of thr table please try

• Correct values = if(hasonevalue(table[stockname]),[portfolio measure],sumx(values(table[stockname]),[portfolio measure]))

## Helpful resources

Announcements

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

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors