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
Kev_Tord1
Frequent Visitor

Calculated column Table - Dates

Hi everyone,

 

I was hoping someone could help me with this report. Essentially my report includes 2 tables.

X_Payroll' that summarizes the various pay periods for an employee and 

X_Employment' that includes "Pay Rate" with their effective date, for that same employee.

 

I would like to carry the matching "Pay Rate" to the associated "PP End Date". 

Note that effective dates don't match with the "PP End Date". The report would select the "Pay Rate" based on it's effective date. "PP End Date" would link to the most recent "Pay Rate" <=  PP End Date. (See example).

 

Another remark: If a field in X_Employment' table is empty, the previous most recent entry would apply. 

 

Please don't hesitate if you have any questions, and thanks in advance for any help!1 - Current.png2 - Expected results.png

1 ACCEPTED SOLUTION

no need to modify the DAX, update the relationship between tables. 

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

13 REPLIES 13
Kev_Tord1
Frequent Visitor

Hi @ryan ,

 

Thanks again for this, it works! As I had submitted a simplification of my current model, I was wondering if you had any idea of how to incorporate the notion of employee in the model. I have added a table to identify employees (Stakeholder ID) will link with the payroll table and Membership_SID will link with the membership with the employment table.

In fine, I am trying to capture the data by employees.

 

Thanks in advance!2024-04-16_08h24_25.png

can't see the whole picture, so can't provide the best soluiton. i think the easiest way is to combine the payroll and employment tables.

 

maybe you can proivde the sample data and the expected output





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks Ryan, I've tried to attach the Pbix file in my early post but can't seem to find the option for file attachment? I was trying to avoid merging both Employment and Payroll tables given that tey are very heavy already. The output result would basically be the same than the one you provided except that it is now looking at several members records (different pay rate) and (different payroll dates). Let me attach the file as soon as I find the option (such a silly situation..) but thanks again for your time here, really.

then pls provide the sample data that you are using for the testing. provide the data of three tables. 

you can just paste the table in the reply. then let me know what's the expected output.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Excellent thank you, please see the 3 tables:

P_Employee

Stakeholder IDMembership_SID
A1Membership1
B2Membership2
C3Membership3

 

 

P_Payroll

Stakeholder IDDate
A12022-07-10
A12022-08-06
A12022-09-03
A12022-10-15
A12023-04-01
A12023-09-19
A12023-09-29
B22023-05-05
B22023-08-12
C32022-12-15
C32023-10-15

 

P_Employment

Membership_SIDEffectivePay Rate
Membership12022-07-1035860.5
Membership12022-10-1237596
Membership12023-03-2540989
Membership12023-09-1945589.6
Membership22022-10-1211000
Membership22023-08-1018500
Membership32022-12-1019000
Membership32023-10-0123500

 

Expected output through P_Payroll:

 

Stakeholder IDDateCalc. column
A12022-07-1035860.5
A12022-08-0635860.5
A12022-09-0335860.5
A12022-10-1537596
A12023-04-0140989
A12023-09-1945589.6
A12023-09-2945589.6
B22023-05-0511000
B22023-08-1218500
C32022-12-1519000
C32023-10-1523500

 

Here you go Ryan, let me know if you need anything else. In short, same approach as what you provided me with, except that now we have several members captured, and was hoping to have their respective salary records carried over to the Payroll table.

 

P_Employee has a relationship with P_Payroll on Employee ID, P_Employee has a relationship with P_Employment on Membership_SID.

This has given me headache for the last few days, really appreciate your help.

Thanks again!

i create a measure , pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks Ryan, that seems to be correct, great! One question though, is it possible that it is not capturing the correct salary for the member B2 on 5/5/2023? I would have expected 11000, wouldn't it be the expected? Or maybe I'm missing something. But thanks so much

no need to modify the DAX, update the relationship between tables. 

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Late thank you @ryan_mayu , I was just able to try now and that is it. I'll do more testing based on my full model but this is just perfect! Thanks much!

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Kev_Tord1
Frequent Visitor

Hi @ryan_mayu , 

Thanks for sending this. I will give it a try. As I am still novice here, would you mind if I ask you for the actual PBi you used to lead to the result (if you have it handy). 

 

**Correction: I had missed that your working file was attached, thanks very much Ryan, will try now.

 

Thanks much!

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ryan_mayu
Super User
Super User

@Kev_Tord1 

pls try this

Column =
VAR a=maxx(FILTER('x_employeement','x_employeement'[effective]=max('x_employeement'[effective])),'x_employeement'[pay rate])
VAR b=maxx(FILTER('x_employeement','x_employeement'[effective]<='x_payroll'[date]&&not(ISBLANK('x_employeement'[pay rate]))),x_employeement[effective])
return if('x_payroll'[date]>max('x_employeement'[effective]),a,maxx(FILTER(x_employeement,'x_employeement'[effective]=b),x_employeement[pay rate]))
 
11.PNG
 
pls see the attachement below
 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.