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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

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 @Anonymous 

 

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 @Anonymous 

 

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/

 

 

Anonymous
Not applicable

@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.

@Anonymous 

 

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/

 

 

 

Anonymous
Not applicable

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

 

 

@Anonymous 

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!




Anonymous
Not applicable

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

 

 

Anonymous
Not applicable

@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
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Solution Authors
Top Kudoed Authors