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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
EricHulshof
Solution Sage
Solution Sage

How to use selectedvalue and column values.

Hello everyone. I have a dataset looking like this:

 

Date ordered:

Date:
1-1-2012
5-6-2013
6-8-2014

This tabel has lots of dates. I use the YEAR value of this table to select a year. 

 

Next i have a table with:

NumberNameActive fromActive till
111Name11-1-201231-12-2100
222Name21-1-201231-12-2012
333Name31-1-201231-12-2013
4556Name41-1-201431-12-2100
5775Name51-1-201431-12-2100
6574Name61-1-201431-12-2100
87544name71-1-201431-12-2100

 

So now i want to create a field, showing wich number was active at the selected date. 

Example i select 2013. this should show up.

 

NumberNameActive fromActive tillWasActive
111Name11-1-201231-12-21001
222Name21-1-201231-12-20120
333Name31-1-201231-12-20131
4556Name41-1-201431-12-21001
5775Name51-1-201431-12-21001
6574Name61-1-201431-12-21001
87544name71-1-201431-12-21001

 

I tried doing this with a measure, but i cannot use columns in a measure. The i tried it using a calculated column, but i can not use selectedvalue in a calculated column. 

The calculated column looks like this:

 

 

WasActive = IF(AND([Selectedvalue] >= Table2[Active from].[Year];[Selectedvalue] <= table2[Active till].[Year]);1;0) 

 

 

 

Where i now have the simple measure:

 

 

Selectedvalue = 2013 

 

 

 

I used to have the selected value take the value from the slicer, but that ofcourse does not comply with the calculated column.
 
Anyone knows how i can fix this?
 
Thankyou.

Quality over Quantity


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


1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @EricHulshof ,

 

You need to create a measure if you want dynamic values.

Measure =
VAR a =
    YEAR ( SELECTEDVALUE ( 'Table'[Active from] ) )
VAR b =
    YEAR ( SELECTEDVALUE ( 'Table'[Active till] ) )
RETURN
    IF (
        SELECTEDVALUE ( 'Table (2)'[Year] ) >= a
            && SELECTEDVALUE ( 'Table (2)'[Year] ) <= b,
        1,
        0
    )

Here is the result.

2-1.PNG

Here is my test file for your reference.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

1 REPLY 1
v-eachen-msft
Community Support
Community Support

Hi @EricHulshof ,

 

You need to create a measure if you want dynamic values.

Measure =
VAR a =
    YEAR ( SELECTEDVALUE ( 'Table'[Active from] ) )
VAR b =
    YEAR ( SELECTEDVALUE ( 'Table'[Active till] ) )
RETURN
    IF (
        SELECTEDVALUE ( 'Table (2)'[Year] ) >= a
            && SELECTEDVALUE ( 'Table (2)'[Year] ) <= b,
        1,
        0
    )

Here is the result.

2-1.PNG

Here is my test file for your reference.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.