WhatTheFact_Logo_Transparent_353x76px

Why is it sometimes not possible to select the exact number in the what-if parameter and how can this be solved?

This post is also available in: Deutsch

I like working pretty much with the what-if parameter in Power BI. With the help of this, it is possible to run through corresponding scenarios in a very fine-grained manner. What would my operating result look like if I can increase my sales by a factor of 2? How would it look with 1.5? And how about 2.35? I am aware that these increases are extremes. But with the what-if parameter, such evaluations go very easily with a single slider.

Problem the what-if parameter does not work, the exact number cannot be set

However, there is occasionally the case that exact values cannot be set. Let’s take the case just mentioned as an example. I would like to evaluate the development of my sales, accurate to 0.01 points. Accordingly, I create a what-if parameter:

Creating a what-if parameter
Creating a what-if parameter

As range I would like to be able to select from -20 to 20 and the individual values should increase by 0.01 points:

Fine granular settings of the what-if parameter
Fine granular settings of the what-if parameter

Now when I try to adjust the slicer of the what-if parameter to 1, 1.5 or 2.35 something strange happens, I don’t get the slicer set exactly to the value I want:

What-if parameter does not work
What-if parameter does not work

Reason: Limitation to 1002 values per slicer

What is the reason that I cannot select exact values? Let’s first look at the generated table to see if the values are available at all. The parameter creates a table with the GENERATESERIES function. With a granularity of 0.01, we would need 100 values for a whole number. Since we cover the range from -20 to 20, this would be 40 x 100 = 4,000 individual values. This also is provided by the table:

Generated table provides 4,000 values
Generated table provides 4,000 values

Therefore, it is not the table that is to be blamed. Let’s take a look at the generated DAX code with the Performance Analyzer:

Get DAX code from slicer
Get DAX code from slicer

The DAX code of the slicer looks like this:

// DAX Query
DEFINE
  VAR __DS0Core = 
    VALUES('SalesGrowth'[SalesGrowth])

  VAR __DS0BodyLimited = 
    SAMPLE(1002, __DS0Core, 'SalesGrowth'[SalesGrowth], 1)

EVALUATE
  __DS0BodyLimited

ORDER BY
  'SalesGrowth'[SalesGrowth]

When we execute the query, we immediately notice the problem. The entire series is no longer displayed. There are gaps here compared to the original table:

image 11
Values which are displayed in the slicer

If we take a look at the DAX Query, we can immediately see why this is happening. The following line is to be blamed:

  VAR __DS0BodyLimited =  SAMPLE(1002, __DS0Core, 'SalesGrowth'[SalesGrowth], 1)

The slicer limits the number of values to 1002 individual values! These are selected with the SAMPLE function in the selected range evenly distributed.

Ways to work around that

If you want to work around that, there are a few approaches.

1. restrict table to 1,002 values

The first option is to limit the data set to 1,002 values. In our case, this would be possible by restricting the granularity to one decimal position:

Limitation to one decimal position
Limitation to one decimal position

This way you will get only 400 values instead of 4,000 and the slicer can display all of the corresponding values. However, you have to restrict the granularity a bit to stay within the 1002 line limit:

what if parameter works
What-if-Parameter with restricted selection of 1002 values

2. modification of the slicer

Another option would be to adjust the slicer. For example, as a list or dropdown, the slicer will display the entire list of all values:

All values are displayed as a dropdown list
All values are displayed as a dropdown list

Also, the slicer can be adjusted to a “Less than or equal to” or “Greather than or equal to” slicer:

Less-than-or-equal slicer
Less-than-or-equal slicer

The entire range between the start and end values is then automatically displayed. Consequently, the individual steps that we would actually have liked to see are lost under certain circumstances.

For example, if I wanted to increase the slicer in increments of 5, this variant would provide all numbers between the start and end values and not in increments of five. In addition, the formula of the measure to be evaluated must be adjusted to MAX or MIN of the respective slicer, instead of SELECTEDVALUE as we had it before. Also, the start and end area are always displayed here in the slicer itself, which is probably undesirable according to the scenario.

Conclusion

The what-if parameter is still, from my point of view, one of the best ways to represent changes in a scenario. However, one must be aware of the limitations in the number of values on 1002 lines if one wants to select specific values. From my point of view, a note in Power BI would be a good solution here.

Share:

LinkedIn
Twitter
WhatsApp
Telegram
Email
Print
Denis Selimovic

Denis Selimovic

As a user from the very beginning, Denis Selimovic is passionate about Power BI and everything related to it. In his blog WhatTheFact.bi, he writes about the latest developments in Power BI and provides tips and tricks on the subject. Besides being a Power BI enthusiast, blog author, speaker and principal consultant, he is also co-organizer of the Meetup Power BI User Group Switzerland.

Kommentare:

5 1 vote
Article Rating
Subscribe
Notify of
guest
7 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Sean
Sean
2 years ago

This was great Denis! You should do a YouTube video on this as I have to think many many people have experienced this problem. It’s frustrated me for a year before I found, and now understand, what the heck is going on!

Francisco Ventura
Francisco Ventura
1 year ago

There is another workaround that I was able develop. If your parameters are large and very granular you can add another column to the parameter table which would contain your parameter enclosed by any text character, for example ($100000K). Then your measure could be Value= VALUE(SUBSTITUTE(SUBSTITUTE(SELECTEDVALUE(PARAMETER),”$”,””),”K”,””)). Then instead if using the filter visual, you could use the search visual and type the parameter as $100000K and press enter. I know there are additional steps to this and that you will not have the dial functionality, but at least you would get rid of the start and end area of the filter visual and input specific numbers at a very granular level.

Hope this helps!

Ezgi Naz Aslankara
8 months ago

Hi Denis,

I want you to know that I really like the method of explaining this problem we encountered in Power BI. I was also working on finding a solution to this issue. By creating a new table, I have developed a method that will both solve the performance problem and ensure that all values are reflected correctly without creating “what if parameters”. I wanted you to know that I also referenced your work in my post, since you explained the exact cause of the problem.

The work you have done has been very useful for me to understand the reason for the error, I hope my solution method will be useful for you too 😉

https://medium.com/@ezginazaslankara/the-solution-of-unable-to-input-number-parameter-in-power-bi-9876d8358587

Jeremy
Jeremy
5 months ago

Hi Denis. Thank you for this. I want to go with the 2nd solution but, unlike a normal slicer, it doesn’t look like you can add a search bar this way. Any ideas for a workaround make the dropdown searchable?

7
0
Would love your thoughts, please comment.x
()
x
Wait!

Follow me on LinkedIn and you’ll gain access to valuable insights, expert tips, and industry updates related to Power BI. Stay ahead of the curve and supercharge your analytics skills today!

Supercharge your Power BI skills!