Forum Discussion

AnnaMagnusson's avatar
4 years ago
Solved

Use selectedvalue from slicer in a visual with no interaction

Hi!

Is there a way to get the selectedvalue() from a slicer that has interactions turned off, from the visaul that I'm trying to use the measure on?
 
I've tried using 
PR =
var
A = CALCULATE([ParetoRank], Dim_Machine[Name] = "A", all(Dim_Machine_Comp[Name]))
var B = CALCULATE([ParetoRank], Dim_Machine[Name] = "B", all(Dim_Machine_Comp[Name]))
var selM = SELECTEDVALUE(dim_Machine[Name])
return
SWITCH( TRUE(),
selM = "A", 1,
selM = "B", 2
)
 
or if I change true() against selM and just write "A" instead of selM="A" then it either says I can't use "A" against a true/false or it doesn't show anything.
 
I know this queation has been upp some years ago but it looks like nobody has solved it yet. 
 
The slicer I use is a table dim_machine with columns id (1, 2, 3, 4) and name(A, B, C, D) and another table dim_machine_comp looks exactly the same.
  • parry2k, I think I have solved my problem with another solution.

    I kept the interaction but used removefilters() on the measures that I have in the visual. 

     

    But thanks for helping 🙂

5 Replies

  • AnnaMagnusson well, in this case, create a disconnected table and then use a column from that table in the slicer, in that case, you will be able to get the selectedvalue from the slicer.

     

     

    Follow us on LinkedIn and  to our YouTube channel

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

     

    Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.

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

      You mean add a slicer from another table, that looks exactly like dim_machine, but doesn't have a relation and use 
      var selM = selectedvalue(machine[Name]) 
      and then

      return
      SWITCH( TRUE(),
      selM = "A", 1,
      selM = "B", 2
      )
      because I've tried that but still not workning...
  • AnnaMagnusson yes exactly and it should work. Share pbix file and remove sensitive information before sharing.

     

     

    Follow us on LinkedIn and  to our YouTube channel

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

     

    Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.

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

       

      parry2k , unfortunaly I can't share some pbix since alot of the information is sensitive even if I remove most of it. Sorry if that makes it harder/impossible to solve.

      But when I use a disconnected table as a slicer I still get blank, so it think that I have not selected anything, and just use the default blank option. Other things that I have tried to use is


      contains(dim_machine, dim_machine[name], "A"), A,

      contains(dim_machine, dim_machine[name], "B"), B

       

      within the switch but it just use the first line so only works when "A" is selected in the slicer is that is on the first line. And now I'm looking at keeping the interaction but use removefilter() somehow.

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

      parry2k, I think I have solved my problem with another solution.

      I kept the interaction but used removefilters() on the measures that I have in the visual. 

       

      But thanks for helping 🙂