Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi together, can anybody tell me why this measure is not working? I am selecting the SELECTEDVALUE on a slicer in my report.
thanks, lennart
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)
Solved! Go to Solution.
Hi @Anonymous ,
I agree with AntonioM 's reply. I checked your code and I think the you let SELECTEDVALUE(Data[TimestampForm])>=SELECTEDVALUE(Data[TimestampForm]) will make no sense.
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
)
I think you slicer is created by Data[TimestampFrom] and Data[TimestampTo] columns in same table with your data.
Your visual will be filtered by them directly, your code won't work.
I suggest you to create two DimTables for rangeStart and rangeEnd.
DimStart = CALENDARAUTO()
DimeEnd = CALENDARAUTO()
Measure:
InDateTimeRange =
VAR _rangeStart =
SELECTEDVALUE ( DimStart[Date] )
VAR _rangeEnd =
SELECTEDVALUE ( DimEnd[TimestampTo] )
RETURN
IF (
SELECTEDVALUE ( Data[TimestampFrom] ) >= _rangeStart
&& SELECTEDVALUE ( Data[TimestampTo] ) <= _rangeEnd
&& SELECTEDVALUE ( Data[TimestampTo] ) <> BLANK (),
1,
0
)
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Where are you using this measure? Just looking at it, SELECTEDVALUE(Data[TimestampFrom]) is going to be the same both times you reference it, so the first two conditions should always be true, as they'll be equal every time. Is that what you're finding?
You might need a new table containing dates to use for the slicers, the you can use those to compare.
Hi, a am using this measure in the same table. But with 4 different columns. In the Selection I use ProductTimeStampFrom and ProductTimeStampTo. In the IF part I use the columns TimeFrom and TimeTo. But they are in the same table. I just need to filter the range ob TimeFrom and TimeTo by a value of ProductTimeStampFrom and ProductTimeStampTo..
Hi @Anonymous ,
I agree with AntonioM 's reply. I checked your code and I think the you let SELECTEDVALUE(Data[TimestampForm])>=SELECTEDVALUE(Data[TimestampForm]) will make no sense.
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
)
I think you slicer is created by Data[TimestampFrom] and Data[TimestampTo] columns in same table with your data.
Your visual will be filtered by them directly, your code won't work.
I suggest you to create two DimTables for rangeStart and rangeEnd.
DimStart = CALENDARAUTO()
DimeEnd = CALENDARAUTO()
Measure:
InDateTimeRange =
VAR _rangeStart =
SELECTEDVALUE ( DimStart[Date] )
VAR _rangeEnd =
SELECTEDVALUE ( DimEnd[TimestampTo] )
RETURN
IF (
SELECTEDVALUE ( Data[TimestampFrom] ) >= _rangeStart
&& SELECTEDVALUE ( Data[TimestampTo] ) <= _rangeEnd
&& SELECTEDVALUE ( Data[TimestampTo] ) <> BLANK (),
1,
0
)
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
117 | |
73 | |
58 | |
49 | |
48 |
User | Count |
---|---|
171 | |
122 | |
60 | |
59 | |
56 |