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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
newhopepdx
Resolver I
Resolver I

Filtered Table

tblSalaryModifications records list all changes to an employee's salary or hourly rate. I'm trying to create a measure that will yield the annual Wage for the (slicer) selected emplolyee, by (additionally) filtering the table down to the most recent salary change.
The measure below errors out saying that the table in the VAR curEmp_ is "not available". Where have I gone wrong?
 
Est Annual Wages =
VAR lastedate_ = MAX( 'tblSalaryModifications'[DtAssigned] )
VAR curEmp_ = FILTER( 'tblSalaryModifications', 'tblSalaryModifications'[DtAssigned] = lastedate_ )
VAR estAnnualWage_ =
    IF( curEmp_[Salary] > 0,
    curEmp_[Salary],
    curEmp_[HoursPerWeek] * curEmp_[HourlyRate] * 52
    )
    RETURN estAnnualWage_
1 ACCEPTED SOLUTION

Your code gave me the prodding I needed to work out the solution.

Here's the code that actually works:

Est Annual Wages =
VAR _lastChangetbl = FILTER(
        ALLSELECTED('tblSalaryModifications'),
        'tblSalaryModifications'[DtAssigned] = MAX('tblSalaryModifications'[DtAssigned] ))
VAR _salary = SUMX( _lastChangetbl, [Salary])
VAR _annualHourly = SUMX( _lastChangetbl, [HourlyRate] * [HoursPerWeek] ) * 52
RETURN
    IF(
        _salary > 0,
        _salary,
        _annualHourly
    )

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@newhopepdx , Follow the code of lastest given here

 

Last Qty = Var _max = maxx(filter( ALLSELECTED('tblSalaryModifications'), 'tblSalaryModifications'[EMPID] = max('tblSalaryModifications'[EMPID] )), 'tblSalaryModifications'[DtAssigned])
return
CALCULATE(sumx('tblSalaryModifications',[HoursPerWeek] *[HourlyRate] * 52 ), filter( ('tblSalaryModifications'), 'tblSalaryModifications'[EMPID] = max('tblSalaryModifications'[EMPID]) && 'tblSalaryModifications'[Date] =_max))


Sum Last Qty = sumx(VALUES('tblSalaryModifications'[EMPID]) , [Last Qty])

 

 

 

Latest
https://amitchandak.medium.com/power-bi-get-the-last-latest-value-of-a-category-d0cf2fcf92d0

https://amitchandak.medium.com/power-bi-get-the-sum-of-the-last-latest-value-of-a-category-f1c839ee8...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Your code gave me the prodding I needed to work out the solution.

Here's the code that actually works:

Est Annual Wages =
VAR _lastChangetbl = FILTER(
        ALLSELECTED('tblSalaryModifications'),
        'tblSalaryModifications'[DtAssigned] = MAX('tblSalaryModifications'[DtAssigned] ))
VAR _salary = SUMX( _lastChangetbl, [Salary])
VAR _annualHourly = SUMX( _lastChangetbl, [HourlyRate] * [HoursPerWeek] ) * 52
RETURN
    IF(
        _salary > 0,
        _salary,
        _annualHourly
    )

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.