A step-by-step guide on creating What-if analysis in Power BI.
Power BI Series with DAX
What-if analysis is frequently used to analyze different situations and the consequences that may occur as conditions change.
In this story, we will create a DAX measure for the what-if parameter.
Table of contents.
- Data for use.
- Steps for creating parameters.
In this story, the Power BI Desktop is Version: 2.112.603.0 64-bit (December 2022)
Data for use.
In this story, we will use the Power BI desktop's sample data.
Step 1: Go to Power BI Desktop, click ‘Help’ , then choose the icon ‘Examples’ and press on ‘Sample dataset’.
Step 2: The box below appears after selecting “Sample dataset.” Next, select “Load sample data.”
We will get the dataset of ‘financials’ that we will be using for this article.
Steps for creating what-if parameters.
Step 1: Create a parameter.
First, go to the tab “Modeling” and click on “New parameter”. Then choose “Numeric range”.
- If we have a strategy to set promotions for clients by offering discounts (such as 5%, 10%, 15%, and 20%), we will compare the number of “Sales” for this offer. Therefore, the “Numeric range” was chosen for that purpose.
We can choose the value for each parameters below.
- What will your variable adjust? : For choosing an appropriate filter for your data.
- Name: To edit the table name as required.
- Data type: To choose the appropriate filter for your data.
- Minimum: To set a minimum value.
- Maximum: To set a maximum value.
- Increment: A series of regular consecutive additions.
- To display the slicer on canvas, check the “Add a slicer to this page” box.
After creating the parameter, we will get the new table ‘Parameter’ on “Fields”.
We can do this on the tab “Visual” of the menu “Format visual” on “Visualizations” and then change the field at “Slicer settings” on “Options” to change the pattern slicer from “Single value” to “Vertical list.”
We will also need to create a measure to generate an interactive value and graph. Then go to the next step.
Step 2: Create a “measure”.
We create a visualization “Line and clustered column chart”. And fill value for each field as below.
We will get the chart as shown below.
Next, start to create a DAX measure
- Parameter-SalesValue: Create a measure on the “Parameter” table.
Parameter-SalesValue = SELECTEDVALUE('Parameter'[Parameter])
- Sales Discount: We create a new measure called “Sales Discount” that is calculated by multiplying the sum of Sales (on the “financials” table) by Parameter-SalesValue (on the “Parameter” table). Then, to convert the unit to a percentage, divide the result by 100.
Sales_Discount = ((sum(financials[ Sales])*Parameter[Parameter-SalesValue])/100)
- Sales After Discount: This is a measure for calculating the formula that will show the result of the final price after getting the discount (refer to % discount on the parameter).
Sales_After_Discount = sum(financials[ Sales]) - Parameter[Sales_Discount]
Step 3: Visual for what-if analysis.
It’s time to visual our data !!
- Fill the column in each field as below. Don’t forget to choose “Line and clustered column char”.
- Then we will get the bar chart is shown below (with a 15% discount).
- Finally, we get the report, which includes information about each country, segment, and discount percentage.
Let’s try this all with your real data.
If you require Power Bi File (.pbix), please visit and download it on my google drive.
Other analytics dashboards using Power BI.
- Customer Lifetime Value CLV (LVT) dashboard
- RFM Analysis for Customer Segmentation with Power BI
- Create a Simple Dashboard for Next Purchase Prediction with Power BI
- Calculate new and repeat customers with Power BI using DAX
See you in the next post.
Knowledge Is Endless To Learn. Let’s study together.
I’m available on LinkedIn.
Tubsamon Dusitsopittawong