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

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.