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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
MohamedSalih_12
Regular Visitor

Wrong Total in SUMX

I have two fact tables 

1. Historic Stock prices downloaded from Google sheets with 3 Columns Date, Ticker, Unit Price

2. Stock Buy transactions table with 4 Columns Date, Ticker, Quantity, Unit Price

3. Below is the matrix which contains Date from Calendar Table, Ticker from Bridge Table, Quantity from Transaction table, Last Unit Price from Historical Prices Table with REMOVEFILTERS('Calendar'[Date] applied, all is well so far

MohamedSalih_12_0-1733920310703.png

The issue is with the measure [Amount 2] = SUM('Transaction'[Quantity])* [Last Unit Price]. It works well in the row context of Tickers, but in the context of Date (see 5/7/2024), it multiplies total Quantity with total of the Unit Prices (i.e 392,036.76).

But I want in the Date rows summation of product of each ticker which has to be (95,027.12)

 

I hope I explained the situation well, looking for a corrected measure.

 

1 ACCEPTED SOLUTION

Make the relationship inactive. Use USERELATIONSHIP in your measure.

View solution in original post

6 REPLIES 6
v-nuoc-msft
Community Support
Community Support

Hi @MohamedSalih_12 

 

Thank you very much lbendlin for your prompt reply.

 

Can you tell me if your problem is solved? If yes, please accept it as solution.

 

Regards,

Nono Chen

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

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Thank you for your reply

Somehow, I managed to find a solution for the yesterday's problem. Now I am stuck with another one, please find below

 

I am trying to make a matrix with 
Calendar[Date],   Data[Ticker] and I want to add a measure to return the LAST PRICE for each ticker from Historical Prices table in all the Calendar[Date] rows. Also, it must return Blank if that ticker has no transaction in Transaction table in that Date

I managed to achieve the required result with helper table, please help to achieve the same result without the helper table and see the attached pbix file.  https://drive.google.com/file/d/1pvIsF2q8_2tp9Wrj8sS6drFvkvS7VWj4/view?usp=sharing 

 

My apologies if I could not explain the problem well, please feel free to ask if anything

lbendlin_0-1734038566410.png

 

the below is the expected result after modifying your DAX slightly. It works well if the 'Calendar' and 'Historical_Prices (fact)' tables are disconnected. Once the relationships are made, it does not work as expected. 

I want to know how to make it work while the relationships are active, because I need the relationship for other calculations

 

MohamedSalih_12_0-1734090156664.png

 

Make the relationship inactive. Use USERELATIONSHIP in your measure.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.