Forum Discussion

olimilo's avatar
olimilo
Post Prodigy
8 years ago
Solved

Removing rows based on 1++ criteria

I'm doing this manually on the Excel source file, but I think it could be done natively on Power BI. I looked at the example here but it seems to just select a subset of the data based on the conditions. Given the table below, how can I remove all rows of Client C and Type 3 from the dataset? I tried the following DAX code but I'm getting this error:

 

= Table.SelectRows(#"Replaced Value2", each not Text.Contains([Client] <> "Client C" and [Type] <> "Type 3"))
Expression.Error: 1 arguments were passed to function which expects between 2 and 3.
Details:
    Pattern=
    Arguments=List

 

ClientTypeDate
Client AType 111/20/2017
Client BType 112/15/2017
Client CType 112/4/2017
Client DType 110/24/2017
Client AType 27/5/2017
Client BType 23/17/2017
Client CType 210/2/2017
Client DType 26/19/2017
Client AType 38/25/2017
Client BType 37/17/2017
Client CType 36/29/2017
Client DType 31/2/2018
Client AType 45/25/2017
Client BType 46/14/2017
Client CType 46/20/2017
Client DType 44/21/2017
Client AType 58/18/2017
Client BType 56/14/2017
Client CType 58/17/2017
Client DType 56/29/2017
  • Just add a custom column as follows (case sensitive)

     

    = if [Client] = “Client A” and [Type] = “Type 3” then “remove” else null

     

    then put a filter on the new colum to remove the results. 

3 Replies

  • MattAllington's avatar
    MattAllington
    Community Champion

    Just add a custom column as follows (case sensitive)

     

    = if [Client] = “Client A” and [Type] = “Type 3” then “remove” else null

     

    then put a filter on the new colum to remove the results. 

    • Zubair_Muhammad's avatar
      Zubair_Muhammad
      Community Champion

      olimilo

       

      Also you can create a new Calculated Table using DAX that filters such rows

       

      Go to Modelling Tab >>New Table

       

      New Table =
      EXCEPT (
          TableName,
          FILTER (
              TableName,
              TableName[Type] = "Type 3"
                  && TableName[Client] = "Client C"
          )
      )
    • olimilo's avatar
      olimilo
      Post Prodigy

      Thanks! I just remembered a SWITCH statement could be used here as well, and would require lesser indentations code-wise.