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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Lookup and Max Value Help

 

Hi All,

 

I would like to lookup a value based on the max date and employee job number and return it to a new column for validation.

 

Employee ID Job Number Unique ID Name DatePay Cycle  Pay Validation
123450123450Bob20/04/2020 WeekWeek
123450123450Bob23/11/2020WeekWeek
123450123450Bob15/03/2021FortnightWeek
123451123451Bob26/10/2020WeekWeek
123451123451Bob20/10/2020FortnightWeek

 

Unique ID - combination of Employee ID and Job number

 

Employees can have multiple jobs (0 primary, 1 secondary). I am trying to bring back the most recent secondary job pay cycle into a new column, "Pay Validation"

 

I can't seem to get this working within the same table.

 

Pay Validation =

VAR Latest_Time_ =
CALCULATE (
MAX ( table[Date] ),
FILTER ( ALL ( table[Unique ID] ), table[Unique ID] = table[Unique ID] )
)
RETURN
LOOKUPVALUE (
table[Pay Cycle],
table[Unique ID],table[Unique ID],
'table[Date], Latest_Time_
)

 

Thanks for the help

1 ACCEPTED SOLUTION

Hi,

This calculated column formula works

=LOOKUPVALUE(Data[Pay Cycle],Data[Date],CALCULATE(MAX(Data[Date]),FILTER(Data,Data[Employee ID]=EARLIER(Data[Employee ID])&&Data[Job Number]=1)),Data[Employee ID],Data[Employee ID])

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
Ashish_Mathur
Super User
Super User

Hi,

For 123450, shouldn't the answer be fortnight?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

I am using this for auditing purposes and so 123451 should align with 123450. Row 3 is the latest for 123450 and I can see that week <> fortnight and I can flag this. 

I am confused.  For 123450, the farthest date is 15/3/2021.  The pay scale for that is fortnight.  Therefore in the first four rows of the Pay validation column, shouldn't the answer be Fortnight?  Is my understanding correct?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Not quite.

I am trying to identify the difference in Pay Cycles for employees where their primary job (job number 0) is different to their secondary job (job number 1) and flag this as an issue as this needs to align i.e. if job 0 is fortnight then job 1 should be fortnight as well.

My thinking is to get the latest Pay Cycle using the latest date of employee ID job 1 and put it in the column Pay Validation.
From here there aim is to compare the latest date in job 0 and compare the output of Pay Cycle with Pay validation to see if there are any errors.

Dom1n1c_0-1615939808538.png

 



Does this help?

I have done the following which has sort of worked in the reverse
Pay Validation =
VAR myModel = 'Table'[Employee ID]
VAR MaxDate =
MAXX(
FILTER(
'Table',
'Table'[Employee ID] = EARLIER('Table'[Employee ID])
),'Table'[Date])
RETURN CALCULATE(MAX('Table'[Pay Cycle]),ALL('Table'),'Table'[Date] = MaxDate ,'Table'[Employee ID] = myModel)

Dom1n1c_1-1615939813401.png

 



I can then get the max date in a new column and compare max date = max date, and Pay Validation = Pay Cycle to see any inconsistencies.

I am open to suggestions on how to solve this.

 

Hi,

This calculated column formula works

=LOOKUPVALUE(Data[Pay Cycle],Data[Date],CALCULATE(MAX(Data[Date]),FILTER(Data,Data[Employee ID]=EARLIER(Data[Employee ID])&&Data[Job Number]=1)),Data[Employee ID],Data[Employee ID])

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

This is great, thank you so much for your help!

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.