cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lwibis
New Member

Total by group, skip the duplicate row

Hi,

I am new in DAX. trying to get Total Cons by Code. if there is a duplicate Cons (code 10, only sum one of it which 535).

I was using SUMX, SUMMARIZE, MAX. But got wrong result for code 40. it gave me 3 where it is supposed to be 4.

Any help, would be much appracited!

Wanted the result as below.

Result 
53510
430
440
050
441

The data as follows

ConschargeCode
53552.8610
535-4.5510
012.8310
01.7110
46.5630
012.3530
06.8740
31.5640
11.1140
04.550
412.441
06.5541

 

 

Thanks,

-L

1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @lwibis ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_1-1675907776729.png

2. create measure with below dax formula

Measure =
VAR cur_code =
    SELECTEDVALUE ( 'Table'[Code] )
VAR tmp =
    FILTER ( ALL ( 'Table' ), 'Table'[Code] = cur_code )
VAR tmp1 =
    CALCULATETABLE ( VALUES ( 'Table'[Cons] ), tmp )
RETURN
    SUMX ( tmp1, [Cons] )

3. add table visual with field and measure

vbinbinyumsft_0-1675907752864.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-binbinyu-msft
Community Support
Community Support

Hi @lwibis ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_1-1675907776729.png

2. create measure with below dax formula

Measure =
VAR cur_code =
    SELECTEDVALUE ( 'Table'[Code] )
VAR tmp =
    FILTER ( ALL ( 'Table' ), 'Table'[Code] = cur_code )
VAR tmp1 =
    CALCULATETABLE ( VALUES ( 'Table'[Cons] ), tmp )
RETURN
    SUMX ( tmp1, [Cons] )

3. add table visual with field and measure

vbinbinyumsft_0-1675907752864.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

FreemanZ
Community Champion
Community Champion

hi @lwibis 

 

not sure about the logic behind. Like why cons 1 and 3 is not included in the result? How comes code 50 for cons 0?

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors