Forum Discussion

CMoppet's avatar
CMoppet
Helper IV
1 year ago
Solved

Slicer that Covers Multiple Columns

I have a table called 'WO Raw Data' that contains rows of machine breakdown data.  Each row contains up to four faults, spread over 4 columns.

I am trying to add a slicer to bar chart where the user can select a fault from the list and the chart will count only rows of breakdowns where that fault  appears in any of the four columns.

 

I can't unpivot my data as it impacts other measures and is a very large data set.  So I created a new table, as follows:

 

AllFaults =
DISTINCT(
    UNION(
        SELECTCOLUMNS('WO Raw Data', "Fault", 'WO Raw Data'[Fault Analysis Task2 Level2.2]),
        SELECTCOLUMNS('WO Raw Data', "Fault", 'WO Raw Data'[First Fault Level 2.2]),
        SELECTCOLUMNS('WO Raw Data', "Fault", 'WO Raw Data'[Fault Analysis Task3 Level2.2]),
        SELECTCOLUMNS('WO Raw Data', "Fault", 'WO Raw Data'[Fault Analysis Task4 Level2.2])
    )
)
 
I'm unsure what to do next.  I essentially need a measure that says 'if a user selects a value from the AllFaults[Fault] slicer list, count the rows where the value appears in any of the four columns'
 
Please can someone help?
  • CMoppet , You need to create a measure that will count the rows where the selected fault appears in any of the four columns. 

     

    FaultCount =
    CALCULATE(
    COUNTROWS('WO Raw Data'),
    FILTER(
    'WO Raw Data',
    'WO Raw Data'[Fault Analysis Task2 Level2.2] IN VALUES(AllFaults[Fault]) ||
    'WO Raw Data'[First Fault Level 2.2] IN VALUES(AllFaults[Fault]) ||
    'WO Raw Data'[Fault Analysis Task3 Level2.2] IN VALUES(AllFaults[Fault]) ||
    'WO Raw Data'[Fault Analysis Task4 Level2.2] IN VALUES(AllFaults[Fault])
    )
    )

     

    Add your bar chart visualization.
    Use the FaultCount measure as the value for the bar chart.
    Add the AllFaults[Fault] column to the slicer.

2 Replies

  • CMoppet , You need to create a measure that will count the rows where the selected fault appears in any of the four columns. 

     

    FaultCount =
    CALCULATE(
    COUNTROWS('WO Raw Data'),
    FILTER(
    'WO Raw Data',
    'WO Raw Data'[Fault Analysis Task2 Level2.2] IN VALUES(AllFaults[Fault]) ||
    'WO Raw Data'[First Fault Level 2.2] IN VALUES(AllFaults[Fault]) ||
    'WO Raw Data'[Fault Analysis Task3 Level2.2] IN VALUES(AllFaults[Fault]) ||
    'WO Raw Data'[Fault Analysis Task4 Level2.2] IN VALUES(AllFaults[Fault])
    )
    )

     

    Add your bar chart visualization.
    Use the FaultCount measure as the value for the bar chart.
    Add the AllFaults[Fault] column to the slicer.

    • CMoppet's avatar
      CMoppet
      Helper IV

      Thank you!  This worked perfectly 🙂