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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
PaulKraemer
Advocate II
Advocate II

Referencing a user controlled variable in a measure

Hi,

 

The link below is to a .pbix file with a single matrix visualization that includes a Measure (PctDiff) that computes the percentage difference between an Actual Value and a Target Value.  I have another Measure (Comparison) that returns True if PctDiff is greater than or equal to 0.25 (25%), and otherwise returns False.  

 

UserControlledVariableInMeasure.pbix

 

Rather than hard-coding the percentage on which this comparison is based at 25%, I'd like to give the user of my report the ability to choose this percentage.  

 

My Comparison measure is currently defined as follows:

 

Comparison = IF([PctDiff]>= 0.25, TRUE(), FALSE())
 
... Can anyone tell me if rather than hard-coding the value 0.25 into the Comparison measure, if there is a way I can reference a variable here, and give the user the ability to set this variable elsewhere on my report page?
 
Thanks in advance,
Paul

 

 

1 ACCEPTED SOLUTION

File didn't open for me

 

I create a table, and named the column Percentages.

 

Percentage = GENERATESERIES(0, 100, 1)

 

And a measure

 

Target = 
var percentage = SELECTEDVALUE( Percentage[Percentages] ) / 100
RETURN
SUM( 'Table'[Value] ) * percentage

 

Add a slicer for the user to select from and add the measure a table.

 

Deku_0-1742761003367.png

 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

6 REPLIES 6
PaulKraemer
Advocate II
Advocate II

Thank you @Deku - I just updated to the Feb 2025 release, and I still don't have the Single Value option.  

 

I think that is a different question than my original post.  I will accept your solution for this one and post another question about the Single Value thing.  

 

I appreciate your help!

 

Best regards,
Paul

PaulKraemer
Advocate II
Advocate II

Thank you @Deku - I now realize that my problem was how I configured my slicer.  Rather than selecting a single value, I had it selecting a range of values.  The Style options I see are the following...

 

PaulKraemer_0-1742764255013.png

 

With this set to Dropdown, I am able to select a single value as shown below, and my Comparison logic works as you suggested it would...

 

PaulKraemer_1-1742764402666.png

 

I like what you did in your example better.  It looked like a single entry field (labeled Percentages) below with a cicular control on a horizontal line that you can drag to change the value...

 

PaulKraemer_2-1742764454847.png

 

Would you mind telling me the Slider settings you used to accomplish this?

 

I appreciate your help.

 

Best regards,
Paul

 

 

 

Single Value

 

Deku_1-1742764920441.png

Not sure why you can't see it. I am using Feb-25 release of Power BI


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
Deku
Super User
Super User

You need to have a list of values you'd allow to be selected in a table. 

 

For percentage this could be generated with

 

Percentages =

Generateseries(0,100,1)

 

This would be added a slicer to the report and you could pick it up in your measures with

 

Selectedvalue( percentages[value] ) / 100


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Thank you @Deku - that sounds like a great approach, but I must be doing something wrong.  

 

In the updated file at the link below, I created a calculated table named Percentages as you suggested, and I added a slider that allows the me to select a value from this table.  I changed my Comparison measure to reference SELECTEDVALUE(Percentages[Value])/100 instead of the hard-coded value 0.25, but the value I select in the slider does not seem to have an effect on the the results of my Comparison, which always returns True now.  As a test, I added a measure named PercentSelected defined as follows:

 

PercentSelected = SELECTEDVALUE(Percentages[Value])
 
When I added this measure to my matrix visualization, I hoped it would show the selected value in every row in the Matrix, but it is blank for every row.
 
Here is the link to my updated file, if you don't mind taking a look at it...
 

If you can give me a clue what I am missing, I would greatly appreciate it.
 
Thanks again,
Paul

 

 

File didn't open for me

 

I create a table, and named the column Percentages.

 

Percentage = GENERATESERIES(0, 100, 1)

 

And a measure

 

Target = 
var percentage = SELECTEDVALUE( Percentage[Percentages] ) / 100
RETURN
SUM( 'Table'[Value] ) * percentage

 

Add a slicer for the user to select from and add the measure a table.

 

Deku_0-1742761003367.png

 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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