cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
f_999
Helper II
Helper II

How to create a measure expression that displays columns linked to aggregated values

Hello!
Is it possible to calculate "max_value_category2" in the table below with the measure expression?
I want to output category2 when value is max with a measure expression.
Thank you.

 

f_999_0-1642097579230.png

 

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @f_999 

 

Create a measure like this:

Measure = 
Var _A  = CALCULATE( MAX ( 'Table'[Value] ) , ALLEXCEPT ( 'Table', 'Table'[Category1] ))
return
if ( MAX ( 'Table'[Value] ) = _A , 1, 0)

 

then add Cat 1 and 2 to the table visual, and add Measure to the filter pane of that table visual and set a filter to show the value 1:

VahidDM_0-1642370425164.png

 

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

View solution in original post

7 REPLIES 7
VahidDM
Super User
Super User

Hi @f_999 

 

Create a measure like this:

Measure = 
Var _A  = CALCULATE( MAX ( 'Table'[Value] ) , ALLEXCEPT ( 'Table', 'Table'[Category1] ))
return
if ( MAX ( 'Table'[Value] ) = _A , 1, 0)

 

then add Cat 1 and 2 to the table visual, and add Measure to the filter pane of that table visual and set a filter to show the value 1:

VahidDM_0-1642370425164.png

 

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

@VahidDM 

Hello, Thank you for answering!

This is a great idea. However, I want to display it without the category 2 column.

I want the measure expression to have a category 2 value.

Thank you.

@f_999 

 

You can remove Cat 1 column from the table and it will work fine, otherwise if you are looking for different type of output, please share more details.

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

 

Hello,‘@VahidDM ‘
Thank you for answering.
I'm sorry for the unclear intention.
I want to create "value_max" in the target table with a major expression.

I want to display the value when the value count is maximized.
thank you.

f_999_1-1642470326094.png

 

 

@f_999 

why count value of b is 6 not 4 when the slicer is day >=2022/1/3?





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

Proud to be a Super User!




Hi @ryan_mayu Thank you for answering.

I'm sorry. That is my mistake.

It doesn't matter which character is displayed when the count is the same.

thank you.

f_999_1-1642486315606.png

 

 

@VahidDM,@ryan_mayu 

Hello, thank you very much for your help. I made a major formula using your thoughts, and maybe I could have made it. I am very grateful. If you have any questions, please let me know.

 

f_999_0-1642584957619.png

 
Max_category =
Var _table1 = ADDCOLUMNS('table',
"MAX_value",
CALCULATE(MAX('table'[value]),ALL('table'[category2],'table'[value])))

Var _table2 = ADDCOLUMNS(_table1,
"MAX_value_flag",
if([value] =[MAX_value],1,0))

Var _table3 = FILTER(_table2,[MAX_value_flag]=1)

Var _Max_category = MAXX(_table3,[category2])
return
_Max_category


thank you.

 

Helpful resources

Announcements
November 2022 Update

Check it Out!

Click here to read more about the November 2022 updates!

Power BI Dev Camp Session 27

Ted's Dev Camp

This session walks through creating a new Azure AD B2C tenant and configuring it with user flows and custom policies.

Health and Life Sciences Power BI User Group

Health and Life Sciences Power BI User Group

Power BI specialists at Microsoft have created a community user group where customers in the provider, payor, pharma, health solutions, and life science industries can collaborate.