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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
ryancaralis
Frequent Visitor

Use Parameter to select measure and apply selected measure to color gradient conditional formatting

Hi,

 

This post looks like the same question I have, and didn't have an answer: https://community.fabric.microsoft.com/t5/Desktop/Use-Parameter-to-return-dynamic-measure-field-for-...

 

I'm trying to use a parameter to select between different measures to use for a color gradient in a scatter plot. The parameter looks like this:

ryancaralis_0-1724877851966.png

When I try to use the parameter value directly in the color gradient formatting, it only summarizes by count or count distinct instead of being able to use the measures that should pass to it. As a workaround, I created a measure that returns the selected measure based on the value selected in the parameter, it looks like this:

ryancaralis_1-1724877887303.png

This also doesn't work. When I try to pass this measure to the color conditional formatting, the selection box comes up blank.

 

Is there a way to implement this correctly? I can use bookmarks as a workaround, but would rather use an approach like this and feel like it should work given the tools available.

 

Thanks for the help!

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

Hi @ryancaralis ,

Thanks for amitchandak's reply!

And @ryancaralis , if you want to use field parameter, please change the "SELECTEDVALUE" here into "MAX" and use "Parameter[Parameter]" instead of "Parameter[Parameter Fields]":

vjunyantmsft_0-1724908426310.png


Here I build a sample data myself:

vjunyantmsft_1-1724908467574.png

 

And create these measures:

_House = SUM('Table'[house])
_People = SUM('Table'[people])
People per house = SUM('Table'[people]) / SUM('Table'[house])

And I create Field parameter:

vjunyantmsft_2-1724908532580.png

 

Then use this DAX to create the measure with Field parameter:

Measure 2 = 
VAR _Slicer = MAX(Parameter[Parameter])
RETURN
SWITCH(
    _Slicer,
    "_People", [_People],
    "_House", [_House],
    "People per house", [People per house]
)

Use this measure to set conditional format:

vjunyantmsft_3-1724908598154.png

And the final output is as below:

vjunyantmsft_4-1724908615538.png

vjunyantmsft_5-1724908623947.png

 




 

vjunyantmsft_6-1724908631644.png


And you can also don't use Field parameter, just add another table for slicer like this:

vjunyantmsft_7-1724908672191.png

Then use this DAX to create a measure:

Measure = 
VAR _Slicer = SELECTEDVALUE(Slicer[Field])
RETURN
SWITCH(
    _Slicer,
    "People", [_People],
    "House", [_House],
    "People per house", [People per house]
)

And use this measure to set conditional format:

vjunyantmsft_8-1724908764182.png

And the final output is as before:

vjunyantmsft_9-1724908786527.png

vjunyantmsft_10-1724908794096.png

 

vjunyantmsft_11-1724908802065.png


Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-junyant-msft
Community Support
Community Support

Hi @ryancaralis ,

Thanks for amitchandak's reply!

And @ryancaralis , if you want to use field parameter, please change the "SELECTEDVALUE" here into "MAX" and use "Parameter[Parameter]" instead of "Parameter[Parameter Fields]":

vjunyantmsft_0-1724908426310.png


Here I build a sample data myself:

vjunyantmsft_1-1724908467574.png

 

And create these measures:

_House = SUM('Table'[house])
_People = SUM('Table'[people])
People per house = SUM('Table'[people]) / SUM('Table'[house])

And I create Field parameter:

vjunyantmsft_2-1724908532580.png

 

Then use this DAX to create the measure with Field parameter:

Measure 2 = 
VAR _Slicer = MAX(Parameter[Parameter])
RETURN
SWITCH(
    _Slicer,
    "_People", [_People],
    "_House", [_House],
    "People per house", [People per house]
)

Use this measure to set conditional format:

vjunyantmsft_3-1724908598154.png

And the final output is as below:

vjunyantmsft_4-1724908615538.png

vjunyantmsft_5-1724908623947.png

 




 

vjunyantmsft_6-1724908631644.png


And you can also don't use Field parameter, just add another table for slicer like this:

vjunyantmsft_7-1724908672191.png

Then use this DAX to create a measure:

Measure = 
VAR _Slicer = SELECTEDVALUE(Slicer[Field])
RETURN
SWITCH(
    _Slicer,
    "People", [_People],
    "House", [_House],
    "People per house", [People per house]
)

And use this measure to set conditional format:

vjunyantmsft_8-1724908764182.png

And the final output is as before:

vjunyantmsft_9-1724908786527.png

vjunyantmsft_10-1724908794096.png

 

vjunyantmsft_11-1724908802065.png


Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This is perfect, appreciate the step by step explanation thank you!

amitchandak
Super User
Super User

@ryancaralis , This is an example

Field Parameters- Conditional Formatting: https://amitchandak.medium.com/field-parameters-conditional-formatting-517aacc23fdf

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 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.

October NL Carousel

Fabric Community Update - October 2024

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