Forum Discussion

Red217's avatar
Red217
Icon for Helper III rankHelper III
3 years ago

How to use TREATAS with SelecetedValue

Hi, 

 

i have many slicers to get a measurement,

one of them is a "switch" with several scenarios when i am copying the DAX from the analyzer i get this:

 

VAR __DS0FilterTable5 =
TREATAS({"Worst Case"}, 'Main Case Scenario Slicer'[Case Scenario Slicer])

 

i wanted to the value to be the SELECETEDVALUE('Main Case Scenario Slicer'[Case Scenario Slicer])

 

but it doesnt work, how do i get the TREATAS to work with the actual value selected in the slicer ?

3 Replies

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

    Hi Red217 

    this is done automatically this why it's hard coded. What exactly are you trying to accomplish?

    • Red217's avatar
      Red217
      Icon for Helper III rankHelper III

      Hi , 

      i am trying to run a query that export the current measurements from power bi, 

      the measurement have MANY filters and Slicers and i want to use them dynamically, based on the filter selection the user have seleceted in the report

       

      for example when i review the dax now i get this (as part of it )

      TREATAS({"Worst Case"}, 'Main Case Scenario Slicer'[Case Scenario Slicer])

       

      in the case above the user have selected "worst case" in the filter, but i wanted it to be something like

      TREATAS (selecetedvalue... in the Slicer)

       

      so the code will actually export based on the filter selection and not based on the static code

       

      thanks

       

       

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

    Red217 

    If you are thinking of creating a dynamic calculated table then you have to know that calculated tables do not interact with the filter context thus they cannot be dynamic. If you are creating a measure then none of that would be required.