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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

Measure - Sum distinct values another column ID

Hi,

 

Is there a good way to Sum these Distinct values in a measure? Similar toa measure similar to: Calculate(sum(Table[Amount Billed]))

Calculate(sum(

                Table[Amount Billed])

               )

 

I want the Bill ID to only to count each of those fact columns once "Amount Billed", "Sales Tax", "Enviromental Charge" But sum it up in a measure that I can branch off with other calculations. Is there a better way to do this? Or is this data bad?

 

Totals Being

Amount Billed = 1,579 +1,566+1,377 +1,356 + 1,348 = $7,226

Sales Tax = 144.85 +0+126.48+0+123.7 = $395.03

Thanks!!

Trevor

Sum of Distinct Values.png

 

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

Hi, @Anonymous 

There are too many duplicate data in your table.

It is recommended to select columns ("Amount Billed", "Sales Tax", "Enviromental Charge") and then delete the duplicate values in "Transform Data",

1.png

You can sum distinct values values based on the columns in the new table.

2.png

3.png

You can also try formula as below:

Total Amount Billed = 
var tab=SUMMARIZE('Table','Table'[ID],'Table'[Amount Billed],'Table'[Sales Tax],'Table'[environment charge])
return SUMX(tab,'Table'[Amount Billed])
Total Sales Tax = 
var tab=SUMMARIZE('Table','Table'[ID],'Table'[Amount Billed],'Table'[Sales Tax],'Table'[environment charge])
return SUMX(tab,'Table'[Sales Tax])

Please check my sample file for more details.

 

Best Regards,
Community Support Team _ Eason

 

View solution in original post

2 REPLIES 2
v-easonf-msft
Community Support
Community Support

Hi, @Anonymous 

There are too many duplicate data in your table.

It is recommended to select columns ("Amount Billed", "Sales Tax", "Enviromental Charge") and then delete the duplicate values in "Transform Data",

1.png

You can sum distinct values values based on the columns in the new table.

2.png

3.png

You can also try formula as below:

Total Amount Billed = 
var tab=SUMMARIZE('Table','Table'[ID],'Table'[Amount Billed],'Table'[Sales Tax],'Table'[environment charge])
return SUMX(tab,'Table'[Amount Billed])
Total Sales Tax = 
var tab=SUMMARIZE('Table','Table'[ID],'Table'[Amount Billed],'Table'[Sales Tax],'Table'[environment charge])
return SUMX(tab,'Table'[Sales Tax])

Please check my sample file for more details.

 

Best Regards,
Community Support Team _ Eason

 

karnold
Resolver I
Resolver I

This does look like the data has been duplicated multiple times. You might want to investigate that. But if the data is as expected you could sum the distinct values using a measure like this. 

 

Distinct Amount Billed = 
VAR _DistinctAmountBilled = VALUES('Table'[Amount Billed])
return SUMX(_DistinctAmountBilled,'Table'[Amount Billed])

See:

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors