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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
PowerRon
Post Patron
Post Patron

How to process multiple selections from a slicer?

Hi,
 
I simplified the example here.
Had a slicer where you could choose one value of 'Max' and 'Min'. Based on the choice the bar gets a color.
 
Measure = 
VAR _metric = SELECTEDVALUE('Chosen Values'[ID])
VAR _color =
SWITCH(
    TRUE,
    _metric = 1 && [Sum Quantity] = _maxQTY, "Green",
    _metric = 2 && [Sum Quantity] = _minQTY, "Blue",
    "Light Grey"
)
RETURN _color
 
But now I want to be able to color the Max as well as Min. So instead of SELECTEDVALUE i need something else.
And the SWITCH probably needs to be two times IF?

Who can help how to code this?

regards Ron



 
 
1 ACCEPTED SOLUTION

Hi @PowerRon ,

 

Try the following code:

YOY difference CF = 

VAR _aantalmaanden = 
COUNTROWS(
    ALL('Date'[Month Name Short], 'Date'[Month])
)

VAR _metric = SELECTEDVALUE('Top 3'[Num])

VAR colorall= 
SWITCH(
    TRUE,
     [RANK YOY difference] <= 3 && [YOY difference %] > 0 , "Green",                      -- Top 3 Increases
     [RANK YOY difference] > _aantalmaanden - 3  && [YOY difference %] < 0, "Blue",      -- Top 3 Decreases
     "Light Grey"
)

VAR _color =
SWITCH(
    TRUE,
     _metric = 1 && 
     [RANK YOY difference] <= 3 && [YOY difference %] > 0 , "Green",                      -- Top 3 Increases
     _metric = 2 && 
     [RANK YOY difference] > _aantalmaanden - 3  && [YOY difference %] < 0, "Blue",      -- Top 3 Decreases
     "Light Grey"
)

RETURN
IF(COUNTROWS('Top 3') = 1, _color, colorall)

MFelix_0-1705505171448.png

 

MFelix_1-1705505178372.png

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

10 REPLIES 10
parry2k
Super User
Super User

@PowerRon Thanks for clarifying. 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@PowerRon @I get that but my question is if there is no negative or if there is no positive. 

if there is no negative then you will not get bottom 3 and  if there is no positive then you will never get top 3.

 

Maybe this is whet you want, as I said I am just curious to know.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

you are right @parry2k 

parry2k
Super User
Super User

@PowerRon You already have a great solution from @MFelix  but out of curiosity, I have a question.  Why do you want to check  > 0 or < 0 values for increase and decrease? For example, you can have all positive increases and in this case bottom 3 will be with less increase %. 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

HI @parry2k 

good question.
In my try-out visual I want to show top3 increase and decrease together.
But it depends what you mean by increase/decrease.

If increase top 3 are only posts that increased compared to previous year, so a positive raise, then you have to exclude the negative ones. So, assume 10 out of 12 months decreased, then your top 3 increase will be a top 2.
Same counts for top 3 decrease. Exclude the positive ones.

PowerRon
Post Patron
Post Patron

Hi @PowerRon ,

 

Try the following code:

YOY difference CF = 

VAR _aantalmaanden = 
COUNTROWS(
    ALL('Date'[Month Name Short], 'Date'[Month])
)

VAR _metric = SELECTEDVALUE('Top 3'[Num])

VAR colorall= 
SWITCH(
    TRUE,
     [RANK YOY difference] <= 3 && [YOY difference %] > 0 , "Green",                      -- Top 3 Increases
     [RANK YOY difference] > _aantalmaanden - 3  && [YOY difference %] < 0, "Blue",      -- Top 3 Decreases
     "Light Grey"
)

VAR _color =
SWITCH(
    TRUE,
     _metric = 1 && 
     [RANK YOY difference] <= 3 && [YOY difference %] > 0 , "Green",                      -- Top 3 Increases
     _metric = 2 && 
     [RANK YOY difference] > _aantalmaanden - 3  && [YOY difference %] < 0, "Blue",      -- Top 3 Decreases
     "Light Grey"
)

RETURN
IF(COUNTROWS('Top 3') = 1, _color, colorall)

MFelix_0-1705505171448.png

 

MFelix_1-1705505178372.png

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix 

exactly what I need. Thnx for helping

Ritaf1983
Super User
Super User

Hi @PowerRon 

If i understood you correctly you are trying to catch 2 values from the slicer , you can use min for lowest selection,
max for highest. 

For example, with the simple list, it looks like :

Ritaf1983_0-1705465277493.png

 


your formula will look something like :

Measure = 
VAR  metric_min = min('Chosen Values'[ID])
Var metric_max = max(Chosen Values'[ID])
.
.
.
 
if i missed something 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi @Ritaf1983 

no, that's not what I mean. I will try to upload a pbix today to clarify the issue.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors