Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I am creating a Dashboard with two what-if parameters. Able to create a Scatter plot with Quadrants, changing with respective what-if parameters As shown in the picture.
The Quadrants will change accordingly with what-if parameters.
This is the code used for Color respectively.
I need to create a table, that changes the values with what parameters.
| Sepal Lenght(Average) | Sepal Width(Average | Petal Len(AVG) | Petal Width(AVG) | |
Q 1 | ||||
Q 2 | ||||
Q 3 | ||||
| Q 4 |
Thanks in advance,
Karthik.
Solved! Go to Solution.
Hi @karthikmiriyala,
You can create a new table with two modes to use in formula change calculation mode:
SwitchMode = {"Mean","Median"}
Here are the dynamic measure formulas based on two what-if parameter tables, Quadrant group and mode slicer.
petalLength =
VAR selected =
SELECTEDVALUE ( SwitchMode[Value] )
VAR currQuadrant =
MAX ( 'Table'[Quadrant] )
VAR currpLength =
MAX ( iris[petal_length] )
VAR currpWidth =
MAX ( iris[petal_width] )
VAR c1 =
IF ( currQuadrant <= 2, currpLength <= [spLength], currpLength > [spLength] )
VAR c2 =
IF ( currQuadrant IN { 1, 3 }, currpWidth <= [spWidth], currpWidth > [spWidth] )
RETURN
CALCULATE (
IF (
selected = "Mean",
AVERAGE ( iris[petal_length] ),
IF ( selected = "Median", MEDIAN ( iris[petal_length] ) )
),
FILTER ( ALLSELECTED ( iris ), c1 && c2 )
)+0
petalWidth =
VAR selected =
SELECTEDVALUE ( SwitchMode[Value] )
VAR currQuadrant =
MAX ( 'Table'[Quadrant] )
VAR currpLength =
MAX ( iris[petal_length] )
VAR currpWidth =
MAX ( iris[petal_width] )
VAR c1 =
IF ( currQuadrant <= 2, currpLength <= [spLength], currpLength > [spLength] )
VAR c2 =
IF ( currQuadrant IN { 1, 3 }, currpWidth <= [spWidth], currpWidth > [spWidth] )
RETURN
CALCULATE (
IF (
selected = "Mean",
AVERAGE ( iris[petal_width] ),
IF ( selected = "Median", MEDIAN ( iris[petal_width] ) )
),
FILTER ( ALLSELECTED ( iris ), c1 && c2 )
)+0
sepalLength =
VAR selected =
SELECTEDVALUE ( SwitchMode[Value] )
VAR currQuadrant =
MAX ( 'Table'[Quadrant] )
VAR currspLength =
MAX ( iris[sepal_length] )
VAR currspWidth =
MAX ( iris[sepal_width] )
VAR c1 =
IF ( currQuadrant <= 2, currspLength <= [spLength], currspLength > [spLength] )
VAR c2 =
IF ( currQuadrant IN { 1, 3 }, currspWidth <= [spWidth], currspWidth > [spWidth] )
RETURN
CALCULATE (
IF (
selected = "Mean",
AVERAGE ( iris[sepal_length] ),
IF ( selected = "Median", MEDIAN ( iris[sepal_length] ) )
),
FILTER ( ALLSELECTED ( iris ), c1 && c2 )
)+0
sepalWidth =
VAR selected =
SELECTEDVALUE ( SwitchMode[Value] )
VAR currQuadrant =
MAX ( 'Table'[Quadrant] )
VAR currspLength =
MAX ( iris[sepal_length] )
VAR currspWidth =
MAX ( iris[sepal_width] )
VAR c1 =
IF ( currQuadrant <= 2, currspLength <= [spLength], currspLength > [spLength] )
VAR c2 =
IF ( currQuadrant IN { 1, 3 }, currspWidth <= [spWidth], currspWidth > [spWidth] )
RETURN
CALCULATE (
IF (
selected = "Mean",
AVERAGE ( iris[sepal_width] ),
IF ( selected = "Median", MEDIAN ( iris[sepal_width] ) )
),
FILTER ( ALLSELECTED ( iris ), c1 && c2 )
)+0
Regards,
Xiaoxin Sheng
Hi @karthikmiriyala ,
Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng
Hi @Anonymous,
Thank you very much for the reply, Please find the link for the dataset: https://gist.githubusercontent.com/curran/a08a1080b88344b0c8a7/raw/0e7a9b0a5d22642a06d3d5b9bcbad9890c8ee534/iris.csvhttps://gist.github.com/curran/a08a1080b88344b0c8a7
these are the fields
sepal_length,sepal_width,petal_length,petal_width,species
in the dataset.
I am trying to create a dashboard that will take two inputs from the user, based on those parameters creating a scatter quadrant plot and changing quadrants with respective user input parameters.
1. Created two what-if parameters.
Sepal Length and Sepal Width.
2. Created a scatter plot with X-axis - Sepal Length and Y-Axis - Sepal Width.
Added Constant line X- axis with what-if parameter value Sepal Length'[Sepal Length Value] and Constant line Y-axis with what-if parameter value 'Sepal Width'[Sepal Width Value].
3. So when the user changes the values in the slicer(what if parameter) in the scatter plot two Constant lines changes accordingly.
4. So as a result based on user inputs we will get 4 dynamic quadrants.
5. For coloring each quadrant points I used the following code which woking fine.
| Sepal Length | Sepal Width | Petal Lenth | Petal Width | |
| Quadrant 1 | ||||
| Quadrant 2 | ||||
| Quadrant 3 | ||||
| Quadrant 4 |
Hi @karthikmiriyala,
You can create a new table with two modes to use in formula change calculation mode:
SwitchMode = {"Mean","Median"}
Here are the dynamic measure formulas based on two what-if parameter tables, Quadrant group and mode slicer.
petalLength =
VAR selected =
SELECTEDVALUE ( SwitchMode[Value] )
VAR currQuadrant =
MAX ( 'Table'[Quadrant] )
VAR currpLength =
MAX ( iris[petal_length] )
VAR currpWidth =
MAX ( iris[petal_width] )
VAR c1 =
IF ( currQuadrant <= 2, currpLength <= [spLength], currpLength > [spLength] )
VAR c2 =
IF ( currQuadrant IN { 1, 3 }, currpWidth <= [spWidth], currpWidth > [spWidth] )
RETURN
CALCULATE (
IF (
selected = "Mean",
AVERAGE ( iris[petal_length] ),
IF ( selected = "Median", MEDIAN ( iris[petal_length] ) )
),
FILTER ( ALLSELECTED ( iris ), c1 && c2 )
)+0
petalWidth =
VAR selected =
SELECTEDVALUE ( SwitchMode[Value] )
VAR currQuadrant =
MAX ( 'Table'[Quadrant] )
VAR currpLength =
MAX ( iris[petal_length] )
VAR currpWidth =
MAX ( iris[petal_width] )
VAR c1 =
IF ( currQuadrant <= 2, currpLength <= [spLength], currpLength > [spLength] )
VAR c2 =
IF ( currQuadrant IN { 1, 3 }, currpWidth <= [spWidth], currpWidth > [spWidth] )
RETURN
CALCULATE (
IF (
selected = "Mean",
AVERAGE ( iris[petal_width] ),
IF ( selected = "Median", MEDIAN ( iris[petal_width] ) )
),
FILTER ( ALLSELECTED ( iris ), c1 && c2 )
)+0
sepalLength =
VAR selected =
SELECTEDVALUE ( SwitchMode[Value] )
VAR currQuadrant =
MAX ( 'Table'[Quadrant] )
VAR currspLength =
MAX ( iris[sepal_length] )
VAR currspWidth =
MAX ( iris[sepal_width] )
VAR c1 =
IF ( currQuadrant <= 2, currspLength <= [spLength], currspLength > [spLength] )
VAR c2 =
IF ( currQuadrant IN { 1, 3 }, currspWidth <= [spWidth], currspWidth > [spWidth] )
RETURN
CALCULATE (
IF (
selected = "Mean",
AVERAGE ( iris[sepal_length] ),
IF ( selected = "Median", MEDIAN ( iris[sepal_length] ) )
),
FILTER ( ALLSELECTED ( iris ), c1 && c2 )
)+0
sepalWidth =
VAR selected =
SELECTEDVALUE ( SwitchMode[Value] )
VAR currQuadrant =
MAX ( 'Table'[Quadrant] )
VAR currspLength =
MAX ( iris[sepal_length] )
VAR currspWidth =
MAX ( iris[sepal_width] )
VAR c1 =
IF ( currQuadrant <= 2, currspLength <= [spLength], currspLength > [spLength] )
VAR c2 =
IF ( currQuadrant IN { 1, 3 }, currspWidth <= [spWidth], currspWidth > [spWidth] )
RETURN
CALCULATE (
IF (
selected = "Mean",
AVERAGE ( iris[sepal_width] ),
IF ( selected = "Median", MEDIAN ( iris[sepal_width] ) )
),
FILTER ( ALLSELECTED ( iris ), c1 && c2 )
)+0
Regards,
Xiaoxin Sheng
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 97 | |
| 70 | |
| 50 | |
| 42 | |
| 40 |