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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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]) )

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]) )

@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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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