Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon'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.
Let us take up a scenario where we have customers associated with a store. The store generates a monthly reporting on what their total sales are, and on the report, the total sales metric is summarised at a customer level. Just imagine a table displaying all these customers with the total sales they generated for the store every month. Over time, the number of rows in the table will keep on increasing.
The above scenario can create performance issues in Power BI when working with Big Data or where we have nearly million customers worth of data to display. From a user point of view, this can be quite challenging where users must wait to get the whole table loaded at the first instance.
But, what if there was a way, we can default the table to display only certain number of rows and then let the user control how many rows they want to see in the table visual?
From this point, we will talk about What-If Parameters and how they can be seamlessly used to achieve this functionality.
What-if parameters gives you a capability to drive your calculations using the values that the user inputs on the report page.
As I will not be going into the details on What-If parameters, kindly refer the following article by RADACAD on this topic. https://radacad.com/power-bi-what-if-parameters
Let us take up a very simple example to illustrate the user control on number of rows to be displayed. In the image shown below, I have got a simple dataset with just 2 columns. One is MONTH column and the other is the TOTAL SALES generated every month.
Let us now create a What-If parameter. To do this: Go to Modelling tab --> New Parameter as shown below:
Once you click on the “New Parameter” option, the following window appears:
Let us look at the different options on the window above:
Let us fill up the values in the window for our example.
The maximum value I have taken here is 12, as we have total 12 calendar months. This value will be different in other scenarios where the volume of data is larger, so if there are 10,000 rows in the data, then one can put maximum value as 10,000. I have also taken the default value as 1, because I want at least one row in my visual to get displayed when no user input is entered. This can also be defaulted to all rows.
The moment you hit OK in the above window; under the Fields Pane a table is created for the defined parameter.
This table has got a measure with the same name as the table. When you click on this table you see following DAX expression:
This is just generating a series with minimum and maximum value that we provided above for the parameter and incrementing it by 1. Details on GENERATESERIES can be found on official Microsoft’s document page: https://docs.microsoft.com/en-us/dax/generateseries-function
So far, the process was simple. From here starts the real challenge. How can we use this parameter in our source table to control what user wants to see on the visual? We just need to perform one more step and we will see the magic. The parameter by default is created as a slicer as shown below:
I want my parameter to accept minimum and maximum value. So, like the normal slicers in Power BI, I choose the BETWEEN option to design it the way I am looking for.
Now, our task is to drive our table visual by changing values in the parameter slicer. Just one more step away from our goal. Create the following measure in your main table with monthly sales:
So, this is the measure we need. Now, let use see how this works. We add this calculated measure to the table visual as shown below along with the month column:
We have Sales by Month. Now, start changing the values in the parameter window and the table starts displaying the number of rows based on the range selected.
This is how we can give users control on the volume of data they want to see on the report.
Hopefully, this article helps everyone out there!
-Pragati
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.