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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Set measure value based on slicer selection

Good afternoon

 

I would be grateful for some help with the following issue.

I have 2 measures Cardcount and Cardpos, which I think I need to make act like two variables and I do not know how.

I need to set each measure to be a value of either "Higher" or "Lower", depending on what I select in a slicer.

I created a table that looks like this

FocusConvPosit
TSR IssueHigherLower
Overall EngagementLowerLower
TSR EngagementLowerHigher
All GoodHigherHigher

 

I created a slicer that uses the values in the Focus column. I created my first measure

FocSel = SELECTEDVALUE(tblFocus[Focus])
Now I want the measure CardCount to equal the value in tblfocus(Conv) and the measure cardpos to equal tblfocus(posit).
 
I then created this measure to try to set the value
Focal =
Switch(
True()
tblfocus[focsel] = "All Good",calculate([cardcount] = "Higher"),
tblfocus[focsel] = "All Good", calculate([cardpos] = "Higher")
etc
)
I tried to use the above as I was unable to make the measures set to the string value.
When I created the measures cardcount and cardpos I used the statement cardcount =""
 
I think i have gone wrong in 
1. I don't know how to use the slicer to set a variable
2. Setting the measure to "" keeps it at a null value
3. refer to point 1
 
I look forward to someone educating me on how to move this along. I am new to this and youtube tutorials are a little hit and miss. I appreciate any guidance.
 
Lola
 
 
1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey @Anonymous ,

I have to admit that I do not fully understand what challenges you have to tackle.

 

No matter, if you are using a slicer based on the column focus you can use this snippet to create two variables in every measure that you want to "react" on the slicer selection

some measure = 

var selectedConv = SELECTEDVALUE( 'Table'[Conv] , BLANK() ) //provide a default value or consider making the focus slider a single selection
var selectedposit = SELECTEDVALUE( 'Table'[Posit] , BLANK() ) //provide a default value or consider making the focus slider a single selection
return

SWITCH(
    TRUE()
        , selectedConv = "Higher" && selectedposit = "Lower"
            , 1 //put you measure definiton here
        , selectedConv = "Higher" && selectedposit = "Higher"
            , 2
        , selectedConv = "Lower" && selectedposit = "Higher"
            , 3
        , selectedConv = "Lower" && selectedposit = "Lower"
            , 4
)

You are not restricted to use SELECTEDVALUE with the column that is used on a slicer, the default value is fired when more than one value is selected inside the slicer or none (meaning all).

 

Hopefully, this provides an idea on how to tackle your challenge.

 

Regards,

Tom





Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

2 REPLIES 2
TomMartens
Super User
Super User

Hey @Anonymous ,

I have to admit that I do not fully understand what challenges you have to tackle.

 

No matter, if you are using a slicer based on the column focus you can use this snippet to create two variables in every measure that you want to "react" on the slicer selection

some measure = 

var selectedConv = SELECTEDVALUE( 'Table'[Conv] , BLANK() ) //provide a default value or consider making the focus slider a single selection
var selectedposit = SELECTEDVALUE( 'Table'[Posit] , BLANK() ) //provide a default value or consider making the focus slider a single selection
return

SWITCH(
    TRUE()
        , selectedConv = "Higher" && selectedposit = "Lower"
            , 1 //put you measure definiton here
        , selectedConv = "Higher" && selectedposit = "Higher"
            , 2
        , selectedConv = "Lower" && selectedposit = "Higher"
            , 3
        , selectedConv = "Lower" && selectedposit = "Lower"
            , 4
)

You are not restricted to use SELECTEDVALUE with the column that is used on a slicer, the default value is fired when more than one value is selected inside the slicer or none (meaning all).

 

Hopefully, this provides an idea on how to tackle your challenge.

 

Regards,

Tom





Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

@TomMartens 

 

Thank you so much for this. It was in the ballpark of what I required so I was able to adapt what you had and make it work. I really appreciate it, thank you for your time.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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