Forum Discussion

jakubkral's avatar
jakubkral
Frequent Visitor
1 year ago

Field parameter in custom column

Hi all,

I have a problem with DAX code for custom column. I need to select IF condition according to the value in column XYZ to insert TRUE or FALSE for each row if you understand me. I'll try to clarify some more: It looks at the value in XYZ and selects the parameter accordingly and that determines TRUE or FALSE in the custom column. Thank you all in advance for your answers and any advice.

 

IsDOHWithinLimit =
    VAR ParameterValueX =
        SELECTEDVALUE('Parameter X'[Parameter])
    VAR ParameterValueY =
        SELECTEDVALUE('Parameter Y'[Parameter])
    VAR ParameterValueZ =
        SELECTEDVALUE('Parameter Z'[Parameter])
RETURN
SWITCH(
    Sheet1[XYZ],
    "X", IF(Sheet1[Days On Hands] < ParameterValueX, TRUE, FALSE),
    "Y", IF(Sheet1[Days On Hands] < ParameterValueY, TRUE,FALSE),
    "Z", IF(Sheet1[Days On Hands] < ParameterValueZ, TRUE, FALSE)
)

6 Replies

  • jakubkral,

     

    Since SELECTEDVALUE doesn't work with field parameters, try using MAX instead:

     

    IsDOHWithinLimit =
    VAR ParameterValueX =
        MAX ( 'Parameter X'[Parameter] )
    VAR ParameterValueY =
        MAX ( 'Parameter Y'[Parameter] )
    VAR ParameterValueZ =
        MAX ( 'Parameter Z'[Parameter] )
    RETURN
        SWITCH (
            Sheet1[XYZ],
            "X", IF ( Sheet1[Days On Hands] < ParameterValueX, TRUE, FALSE ),
            "Y", IF ( Sheet1[Days On Hands] < ParameterValueY, TRUE, FALSE ),
            "Z", IF ( Sheet1[Days On Hands] < ParameterValueZ, TRUE, FALSE )
        )
    • jakubkral's avatar
      jakubkral
      Frequent Visitor

      Unfortunately, I tried that as well and it didn't work for me either. I really don't know where the problem could be, because I use field parameters for conditional formatting and it responds there in my charts. It doesn't respond to me when defining custom columns.

      • DataInsights's avatar
        DataInsights
        Super User

        jakubkral,

         

        Calculated columns are unable to recognize user filters such as the selected value of a field parameter. Also, would you clarify the logic of comparing a single value in column XYZ to the selected value of a field parameter (this would be a column name or measure name)?