Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

what if parameter is not supporting in IF or SWITCH statements

if statment is:

if (days<=10,"<10",

if (days >10 && days<=20,"10 to 20",

if (days >20 && days<=30,"20 to 30",

if(days >30 && days<=40,"30 to 40", "morethan 40")

 

I need to use what if parameter value in the palce of <=10, >10 && <20 etc

if (days<=whatifparameter value,"<10",

if (days > whatifparameter value && days<=whatifparameter value,"10 to 20" (this is should like whatifparameter value to whatifparameter value),

if (days >whatifparameter value && days<=whatifparameter value,"20 to 30"this is should like whatifparameter value to whatifparameter value),

if(days >whatifparameter value && days<=whatifparameter value,"30 to 40 (this is should like whatifparameter value to whatifparameter value), "morethan 40")

 

could you please help me how to use waht if parameter values in IF or SWITCH statements?

 

 

if what if parameter supports in IF or SWITCH statements and alias names as well, then we can change the x axis values dynamically.

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

You could create measure like below :

measure1 = if (max('Table'[days])<=Parameter1[Parameter1 Value],"<="&""&Parameter1[Parameter1 Value],

if (max('Table'[days]) >Parameter1[Parameter1 Value]&& MAX('Table'[days])<=Parameter2[Parameter2 Value],Parameter1[Parameter1 Value]&"to"&Parameter2[Parameter2 Value],

if (MAX('Table'[days] )>Parameter2[Parameter2 Value] && MAX('Table'[days])<=Parameter3[Parameter3 Value],Parameter2[Parameter2 Value]&"to"&Parameter3[Parameter3 Value],

if(MAX('Table'[days] )>Parameter3[Parameter3 Value]&& MAX('Table'[days])<=Parameter4[Parameter4 Value],Parameter3[Parameter3 Value]&"to"&Parameter4[Parameter4 Value], "morethan"&""&Parameter4[Parameter4 Value]))))

And you will get the below:

vluwangmsft_3-1630996615912.png

 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

 

View solution in original post

2 REPLIES 2
v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

You could create measure like below :

measure1 = if (max('Table'[days])<=Parameter1[Parameter1 Value],"<="&""&Parameter1[Parameter1 Value],

if (max('Table'[days]) >Parameter1[Parameter1 Value]&& MAX('Table'[days])<=Parameter2[Parameter2 Value],Parameter1[Parameter1 Value]&"to"&Parameter2[Parameter2 Value],

if (MAX('Table'[days] )>Parameter2[Parameter2 Value] && MAX('Table'[days])<=Parameter3[Parameter3 Value],Parameter2[Parameter2 Value]&"to"&Parameter3[Parameter3 Value],

if(MAX('Table'[days] )>Parameter3[Parameter3 Value]&& MAX('Table'[days])<=Parameter4[Parameter4 Value],Parameter3[Parameter3 Value]&"to"&Parameter4[Parameter4 Value], "morethan"&""&Parameter4[Parameter4 Value]))))

And you will get the below:

vluwangmsft_3-1630996615912.png

 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

 

amitchandak
Super User
Super User

@Anonymous , if plan to create axis/column, it will not work

 

Assume you have whatif parameter with name param, but this not what you need

 

new measure =

Switch(True() ,

selectedvalue(param[value]) <= 10   "  < 10",

selectedvalue(param[value]) <= 20   "  10 -20 ",

selectedvalue(param[value]) <= 30   "  20 -30 ",

selectedvalue(param[value]) <= 40   "  30 -40 ",

" > 40"

)

 

 

But you need axis /column on the measure, you need dynamic segmentation

 

Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1387187#M626


Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!