Forum Discussion

ArvindJha's avatar
ArvindJha
Helper III
1 year ago
Solved

power bi parameter

Hi Team,

 

Below is data

IDSubjectPrevValueCurrValue
11232527
112324

24

 

Below DAX works :

Flag = IF (
   
    Sheet1[PrevValue] < 27 && Sheet1[CurrValue] >= 27,
    "Yes",
    "No"
)
 
but i want to replace 27 with dynamic value using parameter which doesn't work like below :
FlagParameter = IF (
   
    Sheet1[PrevValue] < [Threshold Value] && Sheet1[CurrValue] >= [Threshold Value],
    "Yes",
    "No"
)
  • Hello ArvindJha

    Try creating a calculated column instead of measure based on the required condition, it will return "Yes" or "No" for each row. Once this calculated column is created, you can use it in your visuals and slicers to filter and display data according to whether the subject meets the specified criteria.

    flag_column =
    if(
    sheet1[prevvalue] < [threshold value] && sheet1[currvalue] >= [threshold value],
    "yes",
    "no"
    )

    Thanks and Regards.

15 Replies

  • ArvindJha Click on "New Parameter" and create a parameter named Threshold Value.
    Set the data type to the appropriate type (e.g., Whole Number) and define the minimum, maximum, and default values.

    Once the parameter is created, it will be available in your data model.
    You can then reference this parameter in your DAX formula.

     

    FlagParameter = IF (
    Sheet1[PrevValue] < 'Parameter Table'[Threshold Value] && Sheet1[CurrValue] >= 'Parameter Table'[Threshold Value],
    "Yes",
    "No"
    )

    • ArvindJha's avatar
      ArvindJha
      Helper III

      Even when i use as measure it does not work :

      FlagParameter = IF (
         
          Sheet1[PrevValue] < Threshold[Threshold Value] && Sheet1[CurrValue] >= Threshold[Threshold Value],
          "Yes",
          "No"
      )
  • Hello ArvindJha 

    It is normal, a calculated column will be refreshed only when you refreshed your dataset
    You have to use a measure to achieve that

    This dax measure returns what you try to achieve

     

    Flag Measure = IF (
    SELECTEDVALUE('Table'[PrevValue]) < 27 && SELECTEDVALUE('Table'[CurrValue]) >= Parameter[Parameter Value],
    "Yes",
    "No"
    )

     

    For the Parameter, I created a new parameter ==> Numeric range

    • ArvindJha's avatar
      ArvindJha
      Helper III

      Even when i use as measure it does not work :

      FlagParameter = IF (
         
          Sheet1[PrevValue] < Threshold[Threshold Value] && Sheet1[CurrValue] >= Threshold[Threshold Value],
          "Yes",
          "No"
      )
      • Cookistador's avatar
        Cookistador
        Super User

        Hi ArvindJha 

         

        It is normal, use the following dax measure instead

         

        Flag Measure = IF (
        SELECTEDVALUE('Sheet1'[PrevValue]) < 27 && SELECTEDVALUE('Sheet1'[CurrValue]) >= Threshold[Threshold Value],
        "Yes",
        "No"
        )

         

        You have to aggregate your column to use a measure

    • Cookistador's avatar
      Cookistador
      Super User

      Hi ArvindJha 

      Follow these steps

      1) create a numeric range with the following parameters

      2) create the following measure
      Flag Measure = IF (
      SELECTEDVALUE('Sheet1'[PrevValue]) < 27 && SELECTEDVALUE('Sheet1'[CurrValue]) >= Threshold[Threshold Value],
      "Yes",
      "No"
      )

      3) Add it in the tableau 

      4) play with the sclicer

      Result with a smaller value

      Result with a higher value

       

      • ArvindJha's avatar
        ArvindJha
        Helper III

        Tried all the above steps still not working 

         

    • Cookistador's avatar
      Cookistador
      Super User

      it is normal, when you create a calculated column, the column will read the static value and then won't change, it is the same with a slicer parameter

      It will change only when you refreshed the semantic model

      The measure will be refresh each time something changed on the visual

    • ArvindJha's avatar
      ArvindJha
      Helper III

      thanks for sharing , this works but i also want to see list of subjects meeting that criteria in filter which is not happening if subject has both yes and no it does not work

       

      • v-echaithra's avatar
        v-echaithra
        Community Support

        Hello ArvindJha

        Try creating a calculated column instead of measure based on the required condition, it will return "Yes" or "No" for each row. Once this calculated column is created, you can use it in your visuals and slicers to filter and display data according to whether the subject meets the specified criteria.

        flag_column =
        if(
        sheet1[prevvalue] < [threshold value] && sheet1[currvalue] >= [threshold value],
        "yes",
        "no"
        )

        Thanks and Regards.

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi ArvindJha ,

    Try this below DAX measure, that has worked for me.

    Flag Measure =
    IF (
        MAX ( 'Table'[PrevValue] ) < [Parameter Value] &&
        MAX ( 'Table'[CurrValue] ) >= [Parameter Value],
        "Yes",
        "No"
    )

    If this reply helped solve your problem, please consider clicking "Accept as Solution" so others can benefit too. And if you found it useful, a quick "Kudos" is always appreciated, thanks! 

     

    Best Regards, 
    Chaithra E.