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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
GuilleATT
Frequent Visitor

New Calculated Column that checks another column for distintc values

Hi,

really appreciate some help here.

I have a Sales table like so:

SalesIDProduct
AShoes
BShirt
BShoes
CShirt
CShirt

 

and I need to add a calculated column so that I know if a certain sale has two or more different products in it ("Combined"):

SalesIDProductCategory
AShoesShoes
BShirtCombined
BShoesCombined
CShirtShirt
CShirtShirt

 

I have tried with DistinctCount, SUMs and IF's with no luck,

Thank you in advanced!

Guille

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@GuilleATT - Perhaps:

Category Column = 
  VAR __Table = SUMMARIZE(FILTER(ALL('Table'),[SalesID]=EARLIER([SalesID])),[Product])
RETURN
  IF(COUNTROWS(__Table)>1,"Combined",[Product])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
jthomson
Solution Sage
Solution Sage

Wouldn't try this as a calculated column, it'd be pretty inefficient, unless you're asking in the DAX forum as you can't use Power Query. In that, I'd just duplicate your table, then group on your sales ID with a distinct count of the product as aggregation. You can then merge that in and use conditional "if merged value = 1 then existing value else combined" type of logic.

 

Probably can be done in DAX with a bunch of filter manipulation

Hi, thanks for your answer, will try this as well to check for effiency.

Greg_Deckler
Community Champion
Community Champion

@GuilleATT - Perhaps:

Category Column = 
  VAR __Table = SUMMARIZE(FILTER(ALL('Table'),[SalesID]=EARLIER([SalesID])),[Product])
RETURN
  IF(COUNTROWS(__Table)>1,"Combined",[Product])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

That worked really nicely, thanks! I will study these functions

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.