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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Anonymous
Not applicable

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
Anonymous
Not applicable

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
Super User
Super User

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.