Forum Discussion

RandomJoe's avatar
RandomJoe
Frequent Visitor
6 years ago

How do you create an "OR" filter?

Power BI filters are this "AND"ing of fields. You can apply the setup of filters for the visual, for the Page, or for the Report.

What if you have "OR" logic you need to handle. Take the following example:

 

 

Last Login > X

Last Login < X

Completed = Yes

Include

Include

Completed = No

Exclude

Include

 

There are a bunch of records to include, but when two conditions occur then exclude those records.

 

Secondly, I want the date (X) to be variable like from a time slicer.

 

How is this best done in Power Bi? I’m guessing this will be a new column.

5 Replies

    • RandomJoe's avatar
      RandomJoe
      Frequent Visitor
      Today = 2/3/2020

      Example:

      X = 30 days

       
         
      Last LoginCompletedResult
      1/1/2020NoExclude
      1/1/2020YesInclude
      1/2/2020NoExclude
      1/2/2020YesInclude
      1/4/2020NoInclude
      1/4/2020YesInclude
      1/21/2020NoInclude
      1/22/2020YesInclude
  • az38's avatar
    az38
    Icon for Community Champion rankCommunity Champion

    Hi RandomJoe 

    for  your scenario its better to use DAX logic.

    for example, you can create calculated column like, then filter by its value

    filterFlag = 
    SWITCH(TRUE(),
    [Completed] = "Yes", "Include",
    [Completed] = "No" && [Last Login] > [X], "Exclude",
    "Include"
    )

     

    do not hesitate to give a kudo to useful posts and mark solutions as solution