cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Simulate monthly payments using List.Dates

Dear BI Community, I have a challanging problem that I would love to get some help with.

 

I have a table called Salaries with the salaries of each employee at the company with columns indicating the start date and termination date of each employment.

EmployeeMonthly SalaryStart DateEnd Date
Employee 1400002019-01-012019-12-31
Employee 2350002019-08-192020-05-27

 

The salary is to be payed the same month (On the 25th) as the Employee has worked. This is what I would like to simulate.

 

Employee 1

The first employee will get payed in full 2019-01-25 (First payment) as well as 2019-12-15 (Last payment).

This is the result I'm looking for:

EmployeeMonthly SalaryDate
Employee 1400002019-01-25
Employee 1400002019-02-25
.........
Employee 1400002019-12-25

 

Employee 2

The second employee is a a lot trickier since he has only worked 10 days of the total of 22 working days of August 2019 (10/22 = 45,5%, 35000 * 0,455 = 15925).

The same logic applies to the last payment (19/21 = 90,5%, 35000 * 0,905 = 31667).

EmployeeMonthly SalaryDate
Employee 2159252019-01-25
Employee 2350002019-09-25
.........
Employee 2316672020-05-25

 

I've tried List.Dates which only allows me to put the duration in days and doesn't even get me close to a solution, at least to my knowledge.

 

Is this possible to achive in Power Query?

 

Any help would be hugely appreciated.

1 REPLY 1
Highlighted
Community Support
Community Support

Re: Simulate monthly payments using List.Dates

Hi @Anonymous ,

By my test, you could create a new table and then merge it with table1. However, if you have a lot of data, the method will be complicated. 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs0tyMmvTE1V0lHyzc8rycipVAhOzEksqgQKBJckFpUouCSWgGRd81IgzFgdhC4FQ6CMiQEQAGkjA0NLXQNDIIJxDI10jQ1RNRgB5YxNkTVY6BpagjlGBroGprpG5kqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t, #"(blank).3" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}, {"(blank).3", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Employee", type text}, {"Monthly Salary", Int64.Type}, {"Start Date", type date}, {"End Date", type date}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {"Employee", "Monthly Salary"}, "Attribute", "Value")
in
    #"Unpivoted Other Columns"
  • Unpivot other columns.

4.PNG

  • create a new table manually

5.PNG

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ3MtU3MjC0VNIBsg0hzFidaCUjrBKxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t, #"Start Date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type date}, {"Start Date", type date}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Start Date"}, Table, {"Value"}, "Table", JoinKind.LeftOuter),
    #"Expanded Table" = Table.ExpandTableColumn(#"Merged Queries", "Table", {"Employee"}, {"Table.Employee"})
in
    #"Expanded Table"
  • Merge queries

6.PNG

 

8.PNG

 

Tips: If you have a lot of data, the method will be complicated.  I suggest you to calculate Monthly Salary directly without the column of Salary Date.

 

If you want to calculate the monthly salary with DAX, please post a dummy file that easier to help.

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Galleries

Galleries

Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries!

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors