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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ValeriaBreve
Post Patron
Post Patron

Issue with sum of a DAX measure in PowerBI

Dear experts,

I am seeking help as DAX is not my specialty. I have 3 tables related through the fist one below (Product Code/TP Code).

I am trying to get a measure that allows me to do this:

 

  2021
TP Code 101112
10line1249
10line2183681
30line5100340500

 

so practically split the units sold of the last table by the product lines of the second table. I was able to do so , only to find that when I remove the product lines and product codes from the table the sum of the measure by month/year is totally wrong vs. the total units as per last table.

What's the right way here to create a measure that will give me the units sold of each product by line with the right behaviour when a high level sum is required?

 

Many thanks for your help here. 

Kind regards

Valeria

 

 

 

Product CodeProduct NameTP Code

1A10
2B20
3C30
4D40

 

TP CodeLineSplit

10line110%
10line290%
30line5100%
40line150%
40line330%
40line55%
40line6

15%

 

Product CodeYearMonthUnits

120211020
120211140
120211290
220211030
220211120
220211210
3202110100
3202111340
3202112500
4 REPLIES 4
V-pazhen-msft
Community Support
Community Support

@ValeriaBreve 


You can actually create the matrix If you are using a measure as the value Please check the pbix for detail.

Vpazhenmsft_5-1635231751932.png

 

Some settings:

1. turn off the subtotals in the format panel

Vpazhenmsft_2-1635231587681.png

2. turn off the stepped layout

Vpazhenmsft_3-1635231627870.png

3. expand the column headers.

Vpazhenmsft_4-1635231677764.png

 

 

Paul Zheng_ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

Hello,

thanks, that works if you go down to the product line - what does not work is if you want the summary just by month, so the total units using this measure.

So to the lowest level of detail (line) it works, but the successive aggregations don't work I believe because the measure is not going to the row detail. 

See below the result of the cards - aggregation of the measure vs. sum of the number of units

 

Thanks!
Kind regards

Valeria

 

ValeriaBreve_0-1635251078315.png

 

V-pazhen-msft
Community Support
Community Support

@ValeriaBreve 
Based on what you have now, it is not possible to builder a proper model with valid relationship.

Vpazhenmsft_0-1635217785863.png

 

You cannot put the Line column together with Month column in one visual since no relationship can be build between table 2 and table 3. Usually, we would have a main table include key columns and relationships with other dimension tables. In your case, all three tables are fact tables, please take a look at Star schema to help dealing with multiple tables.

Understand star schema and the importance for Power BI - Power BI | Microsoft Docs

 

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

Hello,

thanks, the last 2 tables are related through the 1st one (star schema) - definition of product (product code/name/trade). 

Table 2 has a many to many relationship with table one (TP are multiple in each table because even in the dimension table 1 TP code corresponds to multiple products); table 3 has a many to one relationship with table 1 at product code level (product codes are unique on table 1).

I have a measure that is somehow working by multiplying the [Second Table]Split * [Third Table]Units. This gives me the correct split by year/month by product line and trade product.

However, as soon as I want to summarize and get rid of the product line and just a total result by month, the measure does not work any longer. I am guessing that I am not at the right row context level.... but this is where I need help as  I am not an expert with DAX row context level.

Thanks for your help!

Kind regards

Valeria

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

Top Solution Authors