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
Rinku21
Helper III
Helper III

Summarized table in Power BI

Hi,

 

I am trying to create a summarized table but facing some issues. 

Below table is the main table and I need to create a summarized table in which there should be only one region for each Id.

 

IdRegion
1APAC
1APAC
1CHN
2APAC
2EMEA
3NAMER
3NAMER

 

The output should be as below:

IdRegion
1APAC
2APAC/EMEA
3NAMER

 

For Id 1, Occurances of region 'APAC' (2), CHN(1), so the output should be : APAC

For Id 2, Occurances of region 'APAC' (1), EMEA (1), the count is similar so the output should be any random region. Either 'APAC' or 'EMEA'

For Id 3, Occurances Region NAMER (2), so output should be : NAMER

 

Can anyone please help me on that?

 

Thanks,

Poonam

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

Hi @Rinku21,

 

First create a calculated column as below:

Count = CALCULATE(COUNT('Table'[Region]),FILTER(ALL('Table'),'Table'[Id]=EARLIER('Table'[Id])&&'Table'[Region]=EARLIER('Table'[Region])))

Then create a measure as below:

_Region = 
VAR _distinctcount1=CALCULATE(DISTINCTCOUNT('Table'[Count]),FILTER(ALL('Table'),'Table'[Id]=MAX('Table'[Id])))
var _distinctcount2=CALCULATE(DISTINCTCOUNT('Table'[Region]),FILTER(ALL('Table'),'Table'[Id]=MAX('Table'[Id])))
Return
IF(_distinctcount1>1||_distinctcount2=1,CALCULATE(MAX('Table'[Region]),FILTER(ALL('Table'),'Table'[Id]=MAX('Table'[Id])&&'Table'[Count]=MAXX(FILTER(ALL('Table'),'Table'[Id]=MAX('Table'[Id])),'Table'[Count]))),CONCATENATEX(DISTINCT('Table'[Region]),'Table'[Region],"/")
)

Finally you will see:

Annotation 2020-07-21 104046.png

For details,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
v-kelly-msft
Community Support
Community Support

Hi @Rinku21,

 

First create a calculated column as below:

Count = CALCULATE(COUNT('Table'[Region]),FILTER(ALL('Table'),'Table'[Id]=EARLIER('Table'[Id])&&'Table'[Region]=EARLIER('Table'[Region])))

Then create a measure as below:

_Region = 
VAR _distinctcount1=CALCULATE(DISTINCTCOUNT('Table'[Count]),FILTER(ALL('Table'),'Table'[Id]=MAX('Table'[Id])))
var _distinctcount2=CALCULATE(DISTINCTCOUNT('Table'[Region]),FILTER(ALL('Table'),'Table'[Id]=MAX('Table'[Id])))
Return
IF(_distinctcount1>1||_distinctcount2=1,CALCULATE(MAX('Table'[Region]),FILTER(ALL('Table'),'Table'[Id]=MAX('Table'[Id])&&'Table'[Count]=MAXX(FILTER(ALL('Table'),'Table'[Id]=MAX('Table'[Id])),'Table'[Count]))),CONCATENATEX(DISTINCT('Table'[Region]),'Table'[Region],"/")
)

Finally you will see:

Annotation 2020-07-21 104046.png

For details,pls see attached.

 

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

 

Works perfect! Appreciate your reply.

 

Thanks,

Rinku

amitchandak
Super User
Super User

@Rinku21 , Try like

 

concatenatex(summarize(Table,Table[ID], Table[Region]),[Region])

 

https://docs.microsoft.com/en-us/dax/concatenatex-function-dax

Hi @amitchandak ,

 

Thanks for your reply. I need to select the maximum occured region in each row.

As mentioned above, it should be :

IdRegion
1APAC
2APAC/EMEA
3NAMER

 

I tried, concatenatex(summarize(Table,Table[ID], Table[Region]),[Region]) but its not working.

 

It seems we need to use RANKX function. I tried below DAX function. Now, I need to select a region with max count for each row.

 

Capture.PNG

 

Do you have any idea how it can be achieved?

Thank you!

 

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.