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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Filter by Today

I have a table that has columns ValidFromDate, EndDate, ResultID, and ResulType.
I want to filter the table by today's date, and today's value should contain
Today >= ValidFromDate & Today<= EndDate.
For example, In SQL we can use the query
case when getdate() >= ValidFromDate and GETDATE() <= EndDate then 1 else 0 end as active

Is there a way to do that in Power BI?
Regards,

2 ACCEPTED SOLUTIONS
jdbuchanan71
Super User
Super User

@Anonymous 

Are you trying to create a copy of the data or calculate a measure with the filter applied?

For a copy of the table you could use

Table = 
FILTER ( YourTable,
    YourTable[ValidFromDate] <= TODAY() && YourTable[EndDate] >= TODAY()
)

This code would go in as a calculated table. 

If you are doing a calculation and want to apply the filter to the calc it looks like this.

Measure = 
CALCULATE(
    COUNTROWS( YourTable ),
    YourTable[ValidFromDate] <= TODAY(),
    YourTable[EndDate] >= TODAY()
)

 

If this solves your issues please mark it as the solution. Kudos 👍 are nice too.

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

Using the Query editor, you should create a single column of Date from the 2 date columns.  Then build a calendar table and build a relationship from the Date column of the transformed table to the Date column of the Calendar Table.  Build a Date slicer from the Date column of the Calendar Table.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Using the Query editor, you should create a single column of Date from the 2 date columns.  Then build a calendar table and build a relationship from the Date column of the transformed table to the Date column of the Calendar Table.  Build a Date slicer from the Date column of the Calendar Table.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
jdbuchanan71
Super User
Super User

@Anonymous 

Are you trying to create a copy of the data or calculate a measure with the filter applied?

For a copy of the table you could use

Table = 
FILTER ( YourTable,
    YourTable[ValidFromDate] <= TODAY() && YourTable[EndDate] >= TODAY()
)

This code would go in as a calculated table. 

If you are doing a calculation and want to apply the filter to the calc it looks like this.

Measure = 
CALCULATE(
    COUNTROWS( YourTable ),
    YourTable[ValidFromDate] <= TODAY(),
    YourTable[EndDate] >= TODAY()
)

 

If this solves your issues please mark it as the solution. Kudos 👍 are nice too.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.