cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kamsingh11
Helper IV
Helper IV

Help with DAX for correct total

Hello!

 

Need help with creating a measure with DAX to see correct totals for part number.

 

In this example table, one Part Number goes into several Models and sales (qty1) on each part remains same for a given month as part is not unique to the model. Sales of each Model does vary on a given month as shown below. So, we see repeated values for part numbers in a given date and different values for Models in the same rows.

 

Example Table - Each part is linked to specific model and is unique row.

kamsingh11_2-1653132339123.png

 

I am achieving accurate result for Part Number if we select one model at a time. However, it messes up in totals of parts, if we select more than one model or all models. It essentially aggregates all values of same part (repeated values are all aggregated). 

 

So, I am looking for a measure with DAX that can show the sum as single value of Part Number even when we choose multiple Models. Here is the .pbx file: https://drive.google.com/file/d/1psm3q_pHsQPLXVYPyqgkOyU_l4itnokM/view?usp=sharing

 

In below, if I select any part and any model, then I get right information as below.

kamsingh11_3-1653132339135.png

 

However, if I select any part & all models, then data for parts are also aggregated. For example, instead of seeing only 195 as Qty1, now we see 390.

kamsingh11_4-1653132339012.png

 

What can we do avoid summing up parts? Any speific measure that can be used to help here which considers only one value of Part Number. 

 

Any help will be highly appreciated here.

 

Thanks!

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the attached file, that I inserted explicit measures into the visualizations.

 

Quantity one measure: = 
SUMX (
    SUMMARIZE ( 'Table', 'Table'[Part], 'Table'[Part Number], 'Table'[Qty1] ),
    'Table'[Qty1]
)

 

Quantity two measure: = 
SUMX (
    SUMMARIZE ( 'Table', 'Table'[Part], 'Table'[Part Number], 'Table'[Qty2] ),
    'Table'[Qty2]
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the attached file, that I inserted explicit measures into the visualizations.

 

Quantity one measure: = 
SUMX (
    SUMMARIZE ( 'Table', 'Table'[Part], 'Table'[Part Number], 'Table'[Qty1] ),
    'Table'[Qty1]
)

 

Quantity two measure: = 
SUMX (
    SUMMARIZE ( 'Table', 'Table'[Part], 'Table'[Part Number], 'Table'[Qty2] ),
    'Table'[Qty2]
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Thank you! 

Yes, this works great on this example table. I will try to test this on my huge table and let you know if I run into any issues. Thanks again!

Helpful resources

Announcements
August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 24 without aka link and time 768x460.jpg

Ted's Dev Camp - July 28, 2022

Watch Session 24 of Ted's Dev Camp along with past sessions!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors