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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Super User
Super User

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
Super User
Super User

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
Super User
Super User

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors