Forum Discussion

Datavizuserpbi's avatar
4 years ago
Solved

Selectedvalue of a parameter

Hi,

I have a parameter A= GENERATESERIES(1, 3, 1) when i try to use selectedvalue function to get the value of A like this

Value = SELECTEDVALUE('Table'[A], 1) in a calculated column or measure it doesn't work. Value always return 1 even if another value is selected in the slicer .
Calculated Column= SWITCH(Value,
1,Table2[Column X],
2,Table2[Column Y],
3,Table2[Column Z],0
)
So calculated column always return column X or 0 
 
Thank for the help
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Datavizuserpbi ,

     

    I have create a data sample for better understanding:

    1.If you want to dynamically show values based on slicer, you should use measure since calculated column is static which could not dynamically changed.

    And it's a dropdown list , and multiply selections, please use ALLSELECTED() to get all selections:

    Measure = 
    var _sele=ALLSELECTED(A[Value])
    return IF(MAX('Table2'[Column X]) in _sele,1,0)

     

     

    2.Or if you just want to add a column to Table A , please try:

    Column = 
    VAR _S=SWITCH([Value],
    1,MAX('Table2'[Column X]),
    2,MIN('Table2'[Column Y]),
    3,MAX('Table2'[Column Z])
    )
    RETURN CONVERT(_S,STRING)

     

     

    If both are not your expected outputs, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

    Refer to:

    How to Get Your Question Answered Quickly - Microsoft Power BI Community

    How to provide sample data in the Power BI Forum - Microsoft Power BI Community

     

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

4 Replies

  • It depends on what sort of slicer you are using. If you are using a List or Dropdown then SELECTEDVALUE should work, as long as only 1 item is selected. If you are using a Between, Less than or Greater than slicer then SELECTEDVALUE will not work, you would need to use either MIN or MAX

    • Datavizuserpbi's avatar
      Datavizuserpbi
      Icon for Helper I rankHelper I

      Hello, it's a dropdown list and if i select 2 or 3 ,value always return Blank() so the switch return 0 .

      • johnt75's avatar
        johnt75
        Icon for Super User rankSuper User

        Selected Val is just 

        Selected Val = SELECTEDVALUE('Table'[A])
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Datavizuserpbi ,

     

    I have create a data sample for better understanding:

    1.If you want to dynamically show values based on slicer, you should use measure since calculated column is static which could not dynamically changed.

    And it's a dropdown list , and multiply selections, please use ALLSELECTED() to get all selections:

    Measure = 
    var _sele=ALLSELECTED(A[Value])
    return IF(MAX('Table2'[Column X]) in _sele,1,0)

     

     

    2.Or if you just want to add a column to Table A , please try:

    Column = 
    VAR _S=SWITCH([Value],
    1,MAX('Table2'[Column X]),
    2,MIN('Table2'[Column Y]),
    3,MAX('Table2'[Column Z])
    )
    RETURN CONVERT(_S,STRING)

     

     

    If both are not your expected outputs, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

    Refer to:

    How to Get Your Question Answered Quickly - Microsoft Power BI Community

    How to provide sample data in the Power BI Forum - Microsoft Power BI Community

     

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.