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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
chq
Helper II
Helper II

Grouping by Column Contains?

My data looks somethng like this...

Transaction #Type CodeType(Desired Column)
121000LongLong Term
12101TheatreLong Term
121900BaseballLong Term
99104TheatreLong Term
991001Long 1Long Term
61104TheatreTheatre



Is there a way to Group where the transaction number for all rows of the column has a subcategory based on the Type to get the desired column shown above? Meaning If the Type contains Long then all Transaction #s that have a row with Long the new column categorizes that Transaction number for all rows as Long Term

1 ACCEPTED SOLUTION

@chq , Please find the link to pbix. Minor chnage in column formula

https://www.dropbox.com/s/ghbeh6z55erxdtd/GroupTeam.pbix?dl=0

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@chq , create a new column like

New column =
var _1 = countX(filter(table,[Transaction #]=earlier([Transaction #]) && [Type]="Type"),[Transaction #])
return
if(isblank(_1) || _1 =0,[Type],"Long Term")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I have Taken count of long , you have one more countx and create logic

or use in

[Type]="Long"

[Type]="Basketball"

 

or

[Type] in{"Long","Basketball"}

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak I am not sure I understand can you give me an example formula with that logic also applied? Thanks

@chq , Please find the link to pbix. Minor chnage in column formula

https://www.dropbox.com/s/ghbeh6z55erxdtd/GroupTeam.pbix?dl=0

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak great this looks like it works correctly. Where I am confused is how would I add additional levels to this though? 

I can't have the non-designated values reflect as "Type", they will need to follow a logic  where if the new value is not Long then it becomes a different variable


For Example:


Calc = var _1 = COUNTX(FILTER(Sheet1,[Transaction #] =EARLIER([Transaction #]) && CONTAINSSTRING([Type],"Baseball")),[Transaction #])
Return if(ISBLANK(_1),[Type],"Baseball")



Would I be able to have it designate those as Baseball and if the new Calc is not Baseball and  [Type] contains Long then Cacl = Long?




@amitchandak  Would this be able to apply to multiple types, for example if it doesn't contain Long or Baseball but does contain Theatre then it equals Theatre?

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.

Top Solution Authors
Top Kudoed Authors