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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Selectedvalue to determine previous year and pass to variable

Hi, I have an issue. I´m trying to calculate the payroll of the employees of a company based on a year selected in a slicer. The problem is that I need the payroll for the year selected and the previous but in some cases an employee change of unit and his "id" number change too, so when I put the employee his payroll for previous year disapare.

 

These are the measures that I am using:

 

Nómina Actual =
VAR SelectedFecha = SELECTEDVALUE(T2C_Facts_Nominas_PRUEBA[FECHA])
RETURN
CALCULATE(
    SUM(T2C_Facts_Nominas_PRUEBA[Nómina]),
    T2C_Facts_Nominas_PRUEBA[FECHA] = SelectedFecha
)
 
Nómina Anterior =
VAR SelectedFecha = SELECTEDVALUE(T2C_Facts_Nominas_PRUEBA[FECHA])-1
RETURN
CALCULATE(
    SUM(T2C_Facts_Nominas_PRUEBA[Nómina]),
    T2C_Facts_Nominas_PRUEBA[FECHA] = SelectedFecha
)
 
If I manually put the previous year in the formula it works fine, if I use selectedvalue-1 it doesn't work as I would like
 
Thanks in advance
1 REPLY 1
lbendlin
Super User
Super User

Please read about SCD - slowly changing dimensions - and how to handle them in Power BI.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors