Forum Discussion

nix_ferreira's avatar
nix_ferreira
Regular Visitor
2 years ago

Using data segmentation filter results in DAX calculation

Hello!

 

I have a table that has data and one column (stock) that I use as a filter. This column only has null, 0 and 1 values. The thing is: I want to use this column in a data segmentation filter (like the one below), and reference whichever value the user chooses to filter in DAX defined columns for this same table, to create dynamic calculations. That is: I want to get the output of that filter and use it in DAX calculations.

 

 

The column I want to create would have this syntax:

 

new_column = CALCULATE( column_1 - column_2,  stock = user_defined_stock )

 

where this variable here, `user_defined_stock`, is the output of the filter above (null, 0 or 1, or multiple selection if that's even possible). 

 

How can I achieve this? I tried using SELECTEDVALUE for that, but I can't figure out how.

 

4 Replies

  • Hello nix_ferreira

    You can create a variable with the name you specified and enclose the the slicer column you are using with the  Selectedvalue (VAR)
    Please try below.

    new_column =
    VAR user_defined_stock=SELECTEDVALUE(slicercolumn)

    Return
    CALCULATE( column_1 - column_2,  stock = user_defined_stock )

    Please let me know if it solves your requirement. If so, please accept it as a solution, and your kudo is much appreciated.

    • nix_ferreira's avatar
      nix_ferreira
      Regular Visitor

      Hi! That looks like would do the job, but how can I access the output of that data segmentation filter? 

      • Moetazzahran's avatar
        Moetazzahran
        Resolver II

        Hello nix_ferreira,
        What do you mean access the output of the data segmentation filter?
        When you select the value on the slicer, it will automatically be stored as the variable you declared in the measure then it will calculate the value. 
        Can you please clarify?
        Thank you

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi nix_ferreira ,

    Any update on this? Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

    If these also don't help, please share more detailed information and description to help us clarify your scenario to test.

    How to Get Your Question Answered Quickly 

    Regards,

    Xiaoxin Sheng