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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
MNHGaming
Frequent Visitor

Date Sorting (relative or by formula)

I would like to know if it's possible to sort on a BI Visual all of THIS YEAR and the next three months. This should be relative to "today". My table has full dates: day+month+year, month, year, and year + month values.

 

I don't know BI syntax so well, but maybe something like:

 

ColumnYear = Year(Today())

OR
(ColumnYear = Year(Today())+1 AND (ColumnMonth = Jan OR ColumnMonth = Feb OR ColumnMonth = Mar))


I am new-ish to Power BI, so please feel free to dumb down any answers. I'm not even sure where I'd put the code snippet above. I just know the intent 😄

 

I tried using the relative date filters (I was willing to accept 6 months behind and 6 months ahead), but I can't find a way to look both forward and back using the built-in filters, maybe I was using them wrong? Below is my filter set that returns no data (I assume it's using AND not OR on the filters)

MNHGaming_0-1728408223635.png

 

Thank you!

1 ACCEPTED SOLUTION
audreygerred
Super User
Super User

Hi! Add this as a calculated column to your date table, then use it as a filter and filter to 1:

IsInDateRange =
VAR TodayDate = TODAY()
VAR BeginningOfYear = DATE(YEAR(TodayDate), 1, 1)
VAR EndOfNextThreeMonths = EOMONTH(DATE(YEAR(TodayDate), 12, 31), 3)
RETURN
IF(
    'DateTable'[Date] >= BeginningOfYear && 'DateTable'[Date] <= EndOfNextThreeMonths,
    1,
    0
)

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

1 REPLY 1
audreygerred
Super User
Super User

Hi! Add this as a calculated column to your date table, then use it as a filter and filter to 1:

IsInDateRange =
VAR TodayDate = TODAY()
VAR BeginningOfYear = DATE(YEAR(TodayDate), 1, 1)
VAR EndOfNextThreeMonths = EOMONTH(DATE(YEAR(TodayDate), 12, 31), 3)
RETURN
IF(
    'DateTable'[Date] >= BeginningOfYear && 'DateTable'[Date] <= EndOfNextThreeMonths,
    1,
    0
)

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.