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

Filter records from Power BI Summarize table

Hi,

 

I have create a below table in Power BI. I need to get max region value for each Id.

 

Below is the DAX I am using to cretae a table in Power BI:

 

Capture.PNG

 

I need to add one more clause which should return max region for each Id.

In case of Id 2 there are two rows, I need to get only one row with Max region value. So the output should be:

 

IdRegion
1APAC
2EMEA
3NAMER

 

Can anyone please help me on that?

 

Thanks!

2 ACCEPTED SOLUTIONS
mahoneypat
Employee
Employee

Not sure how you are calculating your "max" but here is a table expression that gets your desired result from your example table.  This one determines max alphabetically, but you can substitute in another expression inside the CALCULATE if that is not correct.

 

Main Summary =
ADDCOLUMNS (
    SUMMARIZE ( Main, Main[Id] ),
    "Region", CALCULATE ( MAX ( Main[Region] ) )
)

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

Hi @mahoneypat , @amitchandak ,

 

Thank you so much for your reply!

I tried the below expression and it works perfect.

 

Emp_Count_Region = SUMMARIZE(FILTER(SUMMARIZE(Main , Main[Id], Main[Region] ),
RANKX(
FILTER(SUMMARIZE(Main , Main[Id], Main[Region]), Main[Id]=EARLIER(Main[Id])
),
CALCULATE(count('Main'[Region]), ALLEXCEPT(Main, Main[Id], Main[Region])) , , DESC
) =1
), Main[Id], "Region1", calculate(max(Main[Region])))
 
Thanks!
Rinku

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@Rinku21 , if the basis of Max names, why Rank then?

 

Try like

summarize(Table, Table[id], "Region",max(Table[Region]))

Hi @mahoneypat , @amitchandak ,

 

Thank you so much for your reply!

I tried the below expression and it works perfect.

 

Emp_Count_Region = SUMMARIZE(FILTER(SUMMARIZE(Main , Main[Id], Main[Region] ),
RANKX(
FILTER(SUMMARIZE(Main , Main[Id], Main[Region]), Main[Id]=EARLIER(Main[Id])
),
CALCULATE(count('Main'[Region]), ALLEXCEPT(Main, Main[Id], Main[Region])) , , DESC
) =1
), Main[Id], "Region1", calculate(max(Main[Region])))
 
Thanks!
Rinku
mahoneypat
Employee
Employee

Not sure how you are calculating your "max" but here is a table expression that gets your desired result from your example table.  This one determines max alphabetically, but you can substitute in another expression inside the CALCULATE if that is not correct.

 

Main Summary =
ADDCOLUMNS (
    SUMMARIZE ( Main, Main[Id] ),
    "Region", CALCULATE ( MAX ( Main[Region] ) )
)

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


marceloVVR
Helper I
Helper I

Try using the DISTINCT function. After SUMMARIZE, DISTINCT (Main (ID).

maybe work

Hi @marceloVVR ,

 

Thanks for the reply!

I need to select max region for each id. Using distinct it would be difficult to achieve the desire record.

 

Thanks,

Rinku

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.