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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register 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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Top Solution Authors