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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.