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
tyxanu
Helper I
Helper I

DAX for date range lookup

Hi,

 

Can anyone help me with a calculated column like highlighted below?

 

So I have a DATEDIF of: TODAY() vs a Date column.

The Date values can be in the past/present/future or blank.

The DATEDIF result is therefor a number(negative or positive) or blank.

 

I would like to find a solution in order to create a calculated column which I can add afterwards in a slicer which will act as a filter to provide the following possibility:

 

Slicer options:

a)when A selected, filter only the DATEDIFs (or Dates) which go up to 15 (blank, past or 15 days in the future)

b)when B selected, filter only the DATEDIFs (or Dates) which go up to 30 (blank, past or 30 days in the future)

c)when C selected, filter only the DATEDIFs (or Dates) which go up to 45 (blank, past or 45 days in the future)

 

So basically this time frame must expand by selecting different options from the slicer (must be buttons/dropdown mandatory).

 

Thanks!

2 REPLIES 2
ryan_mayu
Super User
Super User

@tyxanu 

you can try this to create a column

Column = 
VAR _dif=ABS('Table'[date]-today())
return SWITCH(TRUE(),_dif<=15,"A",_dif<=30,"B","C")

11.PNG

however, the problem is we can only assign blank to one category. So I didn't put it in the DAX.





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

Proud to be a Super User!




tyxanu
Helper I
Helper I

Anyone please?

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.