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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
John117
New Member

Create table with what-if parameters

Hello!

 

I'm trying to create a dynamic table with DAX functions where one of the columns shows the value that user input in the what-if parameter. For example if the user enter these values for what-if parameters:

John117_0-1636152444408.png

My table should shows:

John117_1-1636152507567.png


I'm tryng to use this DAX function to create the table, but it don't work (the error message is: too many arguments were passed to the SELECTEDMEASURE function. The maximum argument count fot the function is 0):

John117_2-1636152648489.png

 

Any suggestion?

 

Thank you so much!

1 ACCEPTED SOLUTION
Nathaniel_C
Community Champion
Community Champion

Hi @John117 

Try this:

  • Create a table with one column with the Value names
  • Create the measure below

I used an IF() but use a SWITCH () if there are more values.


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

 

 

Value table =
VAR _curValue1 = 'Value 1'[Value 1 Value]
VAR _curTableValue =
    MAX ( newtable[Value] )
VAR _curValue2 = 'Value 2'[Value 2 Value]
RETURN
    IF ( _curTableValue = "Value 1", _curValue1, _curValue2 )

 





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

Proud to be a Super User!




View solution in original post

6 REPLIES 6
Nathaniel_C
Community Champion
Community Champion

TABLE.PNG


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





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

Proud to be a Super User!




Nathaniel_C
Community Champion
Community Champion

Hi @John117 

Try this:

  • Create a table with one column with the Value names
  • Create the measure below

I used an IF() but use a SWITCH () if there are more values.


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

 

 

Value table =
VAR _curValue1 = 'Value 1'[Value 1 Value]
VAR _curTableValue =
    MAX ( newtable[Value] )
VAR _curValue2 = 'Value 2'[Value 2 Value]
RETURN
    IF ( _curTableValue = "Value 1", _curValue1, _curValue2 )

 





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

Proud to be a Super User!




Hello Nathaniel! 

It works, thank you so much!

Hi @John117 ,
BTW here is my pbix if you might be able to use it.
https://1drv.ms/u/s!AgCd7AyfqZtE3z_A6wH2EyvfloHC?e=x3JuXX 
Thanks again,


Nathaniel





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

Proud to be a Super User!




Hi Nathaniel_C,

I found this is interesting for learning what if parameter. But if there are three or more what if parameters, how could we retrieve the current value, that is, how to modify _curTableValue statement? If we still use MAX, it always returns the biggest  value (value 3 if 3 what if parameter).

thanks

 

Thank you @John117 , it is an interesting problem!





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

Proud to be a Super User!




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors