Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
I have two tables very simply represented below
Extract of employee table which has many columns but these are the two key ones for this issue. each employee has a start date. We track our weekly hours weekly with the week end date being Sunday. I am trying to do a visual that shows Total new employees by week associated with the week end date. So for example the first three in the table below started on 2/1/21. The week end date for that week is Sunday 2/7/21 so I want to show 3 employees started during week ending 2/7/21. I have another table that has the hours data and two of the columns are week start date and week end date. I have tried several ways, power query and DAx to try to get this data and not sure what I am doing wrong. Below the pasted emp table extract I show two other extracts; the hours table and then the result i am looking for. I need to create a graph of total new emps by week. Not sure I explained this correctly but can anyone help??? thank you
Emp data
Hours Table extract
Result I am looking for
Solved! Go to Solution.
See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("RcrBEYAgDETRXjjjLFlJHIqwAoaDZdi9RERuP3lbayAETJQQex4jW6xBIMkvduhto10y8oT8jxwUZYJCdAH37bzu982y3gabe4Pwg/YA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Week Start Date" = _t, #"Week End Date" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Week Start Date", type date}, {"Week End Date", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Table.SelectRows(#"Emp data", (x)=> x[Start Date]>=[Week Start Date] and x[Start Date]<=[Week End Date]){0}[Count], Int64.Type)
in
#"Added Custom"
CODE FOR Emp data table
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZcvRCcAgDAXAXfItpHmatA7QKcT91zBVKIH8HtwY9AoVAgvjgtAsLkhSkzQXYakf4ZA6NbYgluR2Ue5Bni3QQN3J/jYX", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Employee Name" = _t, #"Start Date" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Employee Name", type text}, {"Start Date", type date}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Start Date"}, {{"Count", each Table.RowCount(_), Int64.Type}})
in
#"Grouped Rows"
Dowbload pbix file from here - https://1drv.ms/u/s!Akd5y6ruJhvhug7AWcPW9kkOhHHs?e=KoxVqn
Thank you
See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("RcrBEYAgDETRXjjjLFlJHIqwAoaDZdi9RERuP3lbayAETJQQex4jW6xBIMkvduhto10y8oT8jxwUZYJCdAH37bzu982y3gabe4Pwg/YA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Week Start Date" = _t, #"Week End Date" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Week Start Date", type date}, {"Week End Date", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Table.SelectRows(#"Emp data", (x)=> x[Start Date]>=[Week Start Date] and x[Start Date]<=[Week End Date]){0}[Count], Int64.Type)
in
#"Added Custom"
CODE FOR Emp data table
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZcvRCcAgDAXAXfItpHmatA7QKcT91zBVKIH8HtwY9AoVAgvjgtAsLkhSkzQXYakf4ZA6NbYgluR2Ue5Bni3QQN3J/jYX", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Employee Name" = _t, #"Start Date" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Employee Name", type text}, {"Start Date", type date}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Start Date"}, {{"Count", each Table.RowCount(_), Int64.Type}})
in
#"Grouped Rows"
Dowbload pbix file from here - https://1drv.ms/u/s!Akd5y6ruJhvhug7AWcPW9kkOhHHs?e=KoxVqn
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
68 | |
61 | |
19 | |
17 | |
13 |