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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

DAX Variable + Selected Value with Date and Time

Hi together,

I got an issue with this Dax-Formula. The part with the variable and SelectedValue is not working. I am selecting the value in a visual table. The format of the Selected Value is dd/mm/yyyy hh:mm:ss.

Can anybody help me with this issue?




InDateTimeRange =

 

var _rangeStart= SELECTEDVALUE(Data[TimestampFrom])

 

var _rangeEnd= SELECTEDVALUE(Data[TimestampTo])

 

return

 

IF(

 

SELECTEDVALUE(Data[TimestampFrom]) >= _rangeStart

 

&& SELECTEDVALUE(Data[TimestampTo]) <= _rangeEnd

 

&& SELECTEDVALUE(Data[TimestampTo]) <>BLANK()

 

, 1, 0)

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

If you want to set a dynamic flag for rows based on the date period selected in slicer, I'd suggest you firstly add a new Date table:

Date Slicer = CALENDAR(MIN('Data'[TimestampFrom]),MAX('Data'[TimestampTo])+1 ) 

Then modify your measure like:

InDateTimeRange = 
var _rangeStart= MIN('Date Slicer'[Date])
var _rangeEnd= MAX('Date Slicer'[Date])
return
IF(MAX(Data[TimestampFrom]) >= _rangeStart&& MAX(Data[TimestampTo]) <= _rangeEnd&& MAX(Data[TimestampTo]) <>BLANK(), 1, 0)

Output:

Eyelyn9_0-1653467158421.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

 

If you want to set a dynamic flag for rows based on the date period selected in slicer, I'd suggest you firstly add a new Date table:

Date Slicer = CALENDAR(MIN('Data'[TimestampFrom]),MAX('Data'[TimestampTo])+1 ) 

Then modify your measure like:

InDateTimeRange = 
var _rangeStart= MIN('Date Slicer'[Date])
var _rangeEnd= MAX('Date Slicer'[Date])
return
IF(MAX(Data[TimestampFrom]) >= _rangeStart&& MAX(Data[TimestampTo]) <= _rangeEnd&& MAX(Data[TimestampTo]) <>BLANK(), 1, 0)

Output:

Eyelyn9_0-1653467158421.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

themistoklis
Community Champion
Community Champion

@Anonymous 

Can you try removing the selectedvalue from the if statement and then check if it works ok?

 

InDateTimeRange =

 

var _rangeStartSELECTEDVALUE(Data[TimestampFrom])

 

var _rangeEndSELECTEDVALUE(Data[TimestampTo])

 

return

 

IF(

Data[TimestampFrom] >= _rangeStart

&& Data[TimestampTo] <= _rangeEnd

&& Data[TimestampTo] <>BLANK()

10)

Anonymous
Not applicable

Hi, this is unfortunately not working. The Dax Formula can not find the column in the Data, because it is not aggregated. 

Hi Did you find solution for the above issue? I am facing same problem.

Helpful resources

Announcements
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.

Top Solution Authors