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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
tomislav_mi
Helper II
Helper II

Group by and create custom name for values occuring mulitple times

Hey guys,

Hope all of you are keeping well!

I am looking for a solution that could be used both in Power BI and Excel Data model: 

Having a table like this

AccountCustomerRepPeriod
A1JohnMonth
B1JohnQuarter
C1RebeccaYear
T2BobQuarter
Z2BobDay
U2BobQuarter
E3LewisMonth

 

I would need to group it by Customer column and get a table with a unique customer row like this
but I would like to use my custom name for values that occurs multiple time.

CustomerRepPeriod
1MultiMulti
2BobMulti
3LewisMonth

 
Is that possible?

Thank you all a lot!


2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@tomislav_mi , Create two measures like this and use with customer in visual

 

if(distinctcount(Table[Rep]) >1, "Multi",max(Table[Rep]) )

 

if(distinctcount(Table[Period]) >1, "Multi",max(Table[Period]) )

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

Hi @tomislav_mi,

 

You could create a calculated table as below:

Table 2 = 
SUMMARIZE('Table','Table'[Customer],"Rep",
var _num=CALCULATE(DISTINCTCOUNT('Table'[Rep]),FILTER(ALL('Table'),'Table'[Customer]=EARLIER('Table'[Customer])))
Return
IF(_num>1,"multi",MAX('Table'[Rep])),
"Period",
var _num=CALCULATE(DISTINCTCOUNT('Table'[Period]),FILTER(ALL('Table'),'Table'[Customer]=EARLIER('Table'[Customer])))
Return
IF(_num>1,"multi",MAX('Table'[Period])))

And you will see:

v-kelly-msft_0-1611826629657.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

 

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@tomislav_mi , Create two measures like this and use with customer in visual

 

if(distinctcount(Table[Rep]) >1, "Multi",max(Table[Rep]) )

 

if(distinctcount(Table[Period]) >1, "Multi",max(Table[Period]) )

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 Thank you so much!

This works also, but I am trying to get it done as a calculated table or even at the stage of uploading the data in PowerQuery...

Hi @tomislav_mi,

 

You could create a calculated table as below:

Table 2 = 
SUMMARIZE('Table','Table'[Customer],"Rep",
var _num=CALCULATE(DISTINCTCOUNT('Table'[Rep]),FILTER(ALL('Table'),'Table'[Customer]=EARLIER('Table'[Customer])))
Return
IF(_num>1,"multi",MAX('Table'[Rep])),
"Period",
var _num=CALCULATE(DISTINCTCOUNT('Table'[Period]),FILTER(ALL('Table'),'Table'[Customer]=EARLIER('Table'[Customer])))
Return
IF(_num>1,"multi",MAX('Table'[Period])))

And you will see:

v-kelly-msft_0-1611826629657.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

 

Thank you guys a lot!

@v-kelly-msft @amitchandak 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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