Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Power BI Equivalent to SQL OR condition

I have a SQL statement that retrieves records based on this WHERE clause:

    WHERE a.postingdate >= '2018-01-01' OR  a.backoutdate >= '2018-01-01'

 

Then a have a disconnected date table where users can make their desired date selections via a slicer.  They are basically just filtering down the table of records returned above to their desired recordset.  It doesn't look like I can use the Filters pane, because it doesn't appear to allow the OR condition over two separate columns (postingdate OR backoutdate).

 

I thought a calculated column would do it, with syntax something like this:

    IF ([postingdate] >= DATE(2021,1,1) || [backoutdate] >= DATE(2021,1,1),TRUE,FALSE)
 
The thought now is I can replace the hardcoded Date values with user selected values from the slicer.
   Earliest Selected Date = MIN('Date'[Date])
 
However, the calculated column doesn't seem to have visibility to the Earliest Selected Date measure.  In data view, that measure gives me 1/1/2018, but in report view I can see in a card the same measure returns the correct 1/1/2021, which is the user selected value in the date table.
 
Is there a better way to do this?  Basically allowing the user to filter down a larger dataset using their desired date selection.
1 ACCEPTED SOLUTION
MattAllington
Community Champion
Community Champion

Interesting problem. A calc column won't work if you want the user to select the value. You will need to basically build a Union query to create the filter table and then return a result in a measure. You can place the measure in the table visual or possibly in the visual filters pane (if you don't want to see it in the table).  This should return 1 if the row meets the criteria  it assumes your visual has some row level primary key (or combination of columns that make it a pk)

Show =
COUNTROWS (
    DISTINCT (
        UNION (
            FILTER ( table, table[date1] >= DATE ( 2020, 1, 1 ) ),
            FILTER ( table, table[date2] >= DATE ( 2020, 1, 1 ) )
        )
    )
)

 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

View solution in original post

1 REPLY 1
MattAllington
Community Champion
Community Champion

Interesting problem. A calc column won't work if you want the user to select the value. You will need to basically build a Union query to create the filter table and then return a result in a measure. You can place the measure in the table visual or possibly in the visual filters pane (if you don't want to see it in the table).  This should return 1 if the row meets the criteria  it assumes your visual has some row level primary key (or combination of columns that make it a pk)

Show =
COUNTROWS (
    DISTINCT (
        UNION (
            FILTER ( table, table[date1] >= DATE ( 2020, 1, 1 ) ),
            FILTER ( table, table[date2] >= DATE ( 2020, 1, 1 ) )
        )
    )
)

 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.