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.
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 @v-shex-msft,
Thank you very much for the reply, Please find the link for the dataset: https://gist.githubusercontent.com/curran/a08a1080b88344b0c8a7/raw/0e7a9b0a5d22642a06d3d5b9bcbad9890...
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
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
145 | |
85 | |
66 | |
52 | |
48 |
User | Count |
---|---|
215 | |
90 | |
83 | |
67 | |
59 |