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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.