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

Don'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.

Reply
Anonymous
Not applicable

Selectedvalue is not working

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)

 

1 ACCEPTED 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.

View solution in original post

3 REPLIES 3
AntonioM
Solution Sage
Solution Sage

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.

Anonymous
Not applicable

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.

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!

December 2024

A Year in Review - December 2024

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