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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
kmilarov
Helper II
Helper II

Slicer value does not change in a table (stays Default) and cannot be used as an input for IF measur

Guys, I created a Slicer to input value between 0 and 10. [SelMM Value]. And want to use the selected value in a measurement and/or column in IF function. 

But the problem is that in the table the SelMM Value is always the default one , it does not change to the selected value. On the report view - the SelMM Value is changing following the selection - but not in the measurement 

 

SelMM Value = SELECTEDVALUE('SelMM'[SelMM],10 )
 
=====
 

 

Measure4 =
VAR x = 0
VAR _1 =
    IF ( SUM (Sheet1[B1])     <= 'SelMM'[SelMM Value]   , x + 1 )
VAR _2 =
    IF ( SUM (Sheet1[B2])    <= 'SelMM'[SelMM Value], _1 + 1, _1 )
VAR _3 =
    IF ( SUM (Sheet1[B3])    <= 'SelMM'[SelMM Value]    , _2 + 1, _2 )
RETURN
    IF ( SUM (Sheet1[B4])     <= 'SelMM'[SelMM Value]   , _3 + 1, _3 )
 
1 ACCEPTED SOLUTION
rubayatyasmin
Super User
Super User

Hi, @kmilarov 

 

The issue you're encountering is related to the context in which your slicer is being used. Power BI doesn't maintain slicer selection context in the same way that it maintains row or filter context, which is why you are seeing different behavior in different parts of your report. In your measure, the slicer context isn't accessible directly. Instead, you should use your slicer selection in a way that it modifies the filter context of your calculation.

First, modify your SelMM Value as follows:

 

SelMM Value = MIN('SelMM'[SelMM])

 

Then, in your measure, you should use your SelMM Value directly because it's now a measure and not a column:

 

Measure4 =
VAR x = 0
VAR SelMMValue = [SelMM Value] // Directly use the measure here
VAR _1 =
IF ( SUM (Sheet1[B1]) <= SelMMValue, x + 1 )
VAR _2 =
IF ( SUM (Sheet1[B2]) <= SelMMValue, _1 + 1, _1 )
VAR _3 =
IF ( SUM (Sheet1[B3]) <= SelMMValue, _2 + 1, _2 )
RETURN
IF ( SUM (Sheet1[B4]) <= SelMMValue, _3 + 1, _3 )

 

 

Also, make sure edit interaction is on for slicer selection. 

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


View solution in original post

3 REPLIES 3
rubayatyasmin
Super User
Super User

Hi, @kmilarov 

 

The issue you're encountering is related to the context in which your slicer is being used. Power BI doesn't maintain slicer selection context in the same way that it maintains row or filter context, which is why you are seeing different behavior in different parts of your report. In your measure, the slicer context isn't accessible directly. Instead, you should use your slicer selection in a way that it modifies the filter context of your calculation.

First, modify your SelMM Value as follows:

 

SelMM Value = MIN('SelMM'[SelMM])

 

Then, in your measure, you should use your SelMM Value directly because it's now a measure and not a column:

 

Measure4 =
VAR x = 0
VAR SelMMValue = [SelMM Value] // Directly use the measure here
VAR _1 =
IF ( SUM (Sheet1[B1]) <= SelMMValue, x + 1 )
VAR _2 =
IF ( SUM (Sheet1[B2]) <= SelMMValue, _1 + 1, _1 )
VAR _3 =
IF ( SUM (Sheet1[B3]) <= SelMMValue, _2 + 1, _2 )
RETURN
IF ( SUM (Sheet1[B4]) <= SelMMValue, _3 + 1, _3 )

 

 

Also, make sure edit interaction is on for slicer selection. 

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


Hi again, the slicer and the measurement work perfectly fine , but I face another small problem 🙂  How can I calculate and the total value from the measurements in order to put it on a chart ?  

Now can add / vosualise only the single measurements returned from the above code. And only chart that automatically calculates this total is Waterflow chart, but it does not suite / look good for this data.  See below a screenshot : 

IMG_4738.png

 The measure returns in this example 2-1-1-1-1 variables but I need to simonise them (6). 

Thank you! It works now 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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