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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Chelly
Frequent Visitor

Issue with SELECTEDVALUE in Power BI - Need Help

Hello Power BI community,

I'm encountering an issue with the SELECTEDVALUE function when using a slicer for a specific year. If I choose the year 2020, for instance, the result only includes data for that year (e.g., 1000), but I actually want to retrieve the value for years less than 2020 (e.g., 10000).

Here's the snippet of my code:


_test = CALCULATETABLE(
DISTINCT(table[code]),
table[Statut] = 2,
table[year] < SELECTEDVALUE('YearTable'[Year], 2022),
table[Levels] = 2
)

Any insights or suggestions on how to achieve this would be greatly appreciated! Thanks in advance.

3 REPLIES 3
Anonymous
Not applicable

Hi @Chelly ,

 

You can refer to below steps:

result =
VAR sel_ =
    SELECTEDVALUE ( YearTable[Year] )
RETURN
    IF ( MINX ( 'table', [year ] ) <= sel_, 1, 0 )

vkongfanfmsft_0-1706177053764.png

Best Regards,
Adamk Kong

 

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

lukiz84
Memorable Member
Memorable Member

hi, try:

 

VAR SelectedYear = SELECTEDVALUE('YearTable'[Year], 2022)

_test = CALCULATETABLE(
DISTINCT(table[code]),
table[Statut] = 2,
table[year] < SelectedYear,
table[Levels] = 2
)

Appreciate your efforts, but the results remain unchanged.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.