Forum Discussion

aallman's avatar
aallman
Helper II
1 year ago
Solved

Measure based on Multiple Slicer Selection

Hello!

I have a measure to calculate fail rate. Right now it is actually a couple of measures: one counting all the fails, one counting the total items, and a third that does the calculation to turn the first two into a fail rate. 

What I need to be able to do is have the users select their departments in the slicers and have the measures change to only calculate the fail rate for those departments. I have found a solution using IF ISFILTERED and SELECTED VALUE

if(ISFILTERED(ALL_Fail_History[SynthDept]),'Synthesized Items'[synthDept]=SELECTEDVALUE(ALL_Fail_History[SynthDept])
but this solution doesn't seem to work when multiple departments are selected. This is necessary for my use case. 
Any ideas on how to get this to work even if two or more values are selected in the SynthDept filter?
 
 
  • Hi,

    I am not sure if I understood your question correctly, but please try something like below and check whether it works.
    If you are using ALL DAX function in one of your measures, please try using ALLSELECTED DAX function.

     

    ALLSELECTED function (DAX) - DAX | Microsoft Learn

     

    expected result measure: =
    VAR _failcount = [failcount measure]
    VAR _allitemcount =
        CALCULATE ( [itemcount measure], ALLSELECTED () )
    RETURN
        DIVIDE ( _failcount, _allitemcount )
    

     

6 Replies

  • Hi,

    I am not sure if I understood your question correctly, but please try something like below and check whether it works.
    If you are using ALL DAX function in one of your measures, please try using ALLSELECTED DAX function.

     

    ALLSELECTED function (DAX) - DAX | Microsoft Learn

     

    expected result measure: =
    VAR _failcount = [failcount measure]
    VAR _allitemcount =
        CALCULATE ( [itemcount measure], ALLSELECTED () )
    RETURN
        DIVIDE ( _failcount, _allitemcount )
    

     

    • aallman's avatar
      aallman
      Helper II

      Thank you! That mostly solved the problem, however now I am worried that the filters aren't working correctly. I have 2 tables, one contains the fails and the other contains the total items. Each have the field that I want to filter on, but the tables are not linked. (They are related to a common date table for date filtering currently) Does this ALLSELECTED work in this case? It seems to be only letting the slicer filter the table that it is currently located in (in this case my fail table).

      • Jihwan_Kim's avatar
        Jihwan_Kim
        Super User

        Hi,

        Thank you for your message, and if it is OK, please share your sample pbix file's link (Onedrive link, or Dropbox link, or others), and then I can try to look into it to come up with a proper solution.

        Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi aallman ,
    May I ask if you have gotten this issue resolved?
    If it is solved, please mark the helpful reply or share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.

    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi aallman ,
    I just wanted to kindly follow up to see if you had a chance to review the previous response provided by community members. I hope it was helpful. If yes, please Accept the answer so that it will be helpful to others to find it quickly.
    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi aallman ,
    We haven't heard back from you regarding our last response and wanted to check if your issue has been resolved.
    If our response addressed your query, please mark it as Accept Answer and click Yes if you found it helpful.
    If you have any further questions, feel free to reach out.
    Thank you for being a part of the Microsoft Fabric Community Forum!