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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
TM_AC
Helper II
Helper II

SELECTEDVALUE not working in measure variable?

Hi,

I want to calculate TotalQty from previous year. The current year should be selected by the left slicer.
That means the PrevYear is always the selected year in the slicer minus 1.
Here is what I did:
SelectedValue_A2.png

I used SELECTEDVALUE(dimdatum(Jahr)) to get the selected year. The same formula I used in the measure called SelectedYear, and as you can see, the SELECTEDVALUE(dimdatum(Jahr)) is 2022 if 2022 is selected in the slicer.

But the column SoldQtyPrevYear is empty for some reason.

If I preset the VAR SelectedYear in my measure with 2022 then it works as expected:
SelectedValue_A1.png

 

How do I get this working with SELECTEDVALUE(DimDatum[Jahr])?

9 REPLIES 9
Anonymous
Not applicable

Hi @TM_AC ,

 

Can you share the data type and data format of dimdatum [Jahr]?

Please try using this variable.

VAR SelectedYear = SELECTEDVALUE('dimdatum'[Jahr].[Year])

 

Best Regards,
Community Support Team Gao

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems with it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

@Anonymous , thnks for reply, but could not get there:

SelectedValue_A4.png


 

 

I could not enter .[Year] behind.
The datatype and format is 'whole number'.

SpartaBI
Community Champion
Community Champion

@TM_AC can you return as a final result the VAR SelectedYear (put in the RETURN this var) and put the result in the matrix and screenshot what you get

@SpartaBI thanks for your help,

I added a new measure called 'Test' and put it right to 'SoldQtyPrevYear'.
It shows 2022 if I select 2022 on the slicers, for other years I chose on the slicer it works as well.
It seams that only the measure for 'SoldQtyPrevYear' could not hanlde the SELECTEDVALUE(...).

SelectedValue_A3.png

SpartaBI
Community Champion
Community Champion

Strange, Can you share the file maybe?

How can I share (here)?

SpartaBI
Community Champion
Community Champion

Put it in some sharable drive like dropbox or something similar, or on your own gdrive maybe and make the path to only this file public and share the link

@SpartaBI I asked but unfortunately I am not allowed to share this file due to security issues.

But I think there must be a way to get it solved here.
I did not anything special here just used SELECTEDVALUE(DimDate[Year]) inside my measure.
And for some reason it does not work.

SpartaBI
Community Champion
Community Champion

@TM_AC I admit that it's a mystery to me too. In case the selectedvalue returns 2022 in that filter context and you also put it inside a VAR I can't understand how it returns different results than hard coding 2022 cause everything else ia the same. Try post this question again, maybe someone will understand what we are missing here

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.