Wrong Assignment of DAX Values on Table Visual in PowerBI

I have a situation where I am summing the sales for all products in my Fact table across all time periods.

From SQL side, I am writing the query below and getting the expected result;

SELECT

   ProductName,
  SUM(SaleAmount) AS SaleAmount

FROM dbo.FactSales
GROUP BY ProductName

Result is

ProductName, SaleAmount
Prod1, 100
Prod2, 2000
Prod3, 2500
Prod4, 3500

However when i write this in DAX and place the SalesAmount by ProductName on a table visual in power bi, the SalesAmount are being assigned to a different product like so;
The DAX formula I am using is
SalesAmount = SUM(dbo.FactSales[SaleAmount])

ProductName, SaleAmount
Prod1, 3500
Prod2, 2500
Prod3, 2000
Prod4, 100

What could be the reason for the SalesAmount being assigned to a different product on the table visual in Power BI.

Hi @Eze,

Welcome to the forum. It is quite strange as I believe productName and SaleAmount is in same table and you are not dragging field from other tables? It could be due to some relationship issue, but since you are bringing it from same table, I can rule out this situation.

Can you please provide snapshots of sql query, table visual in power bi and snapshot of your data model in power bi. I believe these 3 snapshots will help us to understand a bit of problem. Really weird for me indeed.

Hi @Eze as @hafizsultan has mentioned if you could attach a sample PBIX then we can have a look for you.

Be sure to check your relationships in Power bi, is the product key mapped to the product key in the fact??

Hi @hafizsultan and @haroonali1000 please find attached screen shots of the PowerBI table, SQL query and the Power Bi relationship between the Products and the Fact.
In my case , TargetAudienceKey and TargetAudience is the ProductKey and ProductName respectivelyRelationship PowerBI-TableView SQLqueries

As you can see, the SalesAmount for products (ie. TargetAudience) have been assigned to the wrong product on Power BI table

Hi @Eze,

Thanks for sharing snapshot. Your data model is very simple and straightforward. I am sure, it’s a mapping issue of product and productkey. Can you check and share distinct Target audience and Target audiencekey as well as snapshot of Target audience table in power bi?

Hi @Eze,

Thanks for sharing @hafizsultan is right the issue seems to be the key mapping.

Sharing an example of the PBIX would be easier but understand its not always possible.

I would also check the steps applied in the query editor for that table to retrace what has happened from source.

Regards,
H

Thanks for posting your question @Eze. To receive a resolution in a timely manner please make sure that you provide all the necessary details on this thread.

Here is a potential list of additional information to include in this thread; demo pbix file, images of the entire scenario you are dealing with, screenshot of the data model, details of how you want to visualize a result, and any other supporting links and details.

Including all of the above will likely enable a quick solution to your question.

Hi @Eze, we’ve noticed that no response has been received from you since the 4th of March. We just want to check if you still need further help with this post? In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the checkbox. Thanks!

Hi @hafizsultan, @haroonali1000

I had to re-do the modelling from scratch to get it working the way I wanted, thanks for your inputs on this