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.
Hello,
I have a query-table which contains this :
Employee | Phase |
Mike | Phase 1 |
Mike | Phase 3 |
Mike | Phase 4 |
Mike | Phase 6 |
Mike | Phase 8 |
Mike | Phase 9 |
Patrick | Phase 1 |
Patrick | Phase 2 |
Patrick | Phase 5 |
Patrick | Phase 4 |
Sophia | Phase 3 |
Sophia | Phase 5 |
Sophia | Phase 7 |
Sophia | Phase 8 |
Annie | Phase 2 |
Annie | Phase 3 |
Annie | Pahse 5 |
Annie | Phase 6 |
Annie | Phase 7 |
Annie | phase 8 |
I would like to add a column which is a sort of counter :
Employee | Phase | Counter |
Mike | Phase 1 | 1 |
Mike | Phase 3 | 2 |
Mike | Phase 4 | 3 |
Mike | Phase 6 | 4 |
Mike | Phase 8 | 5 |
Mike | Phase 9 | 6 |
Patrick | Phase 1 | 1 |
Patrick | Phase 2 | 2 |
Patrick | Phase 5 | 3 |
Patrick | Phase 4 | 4 |
Sophia | Phase 3 | 1 |
Sophia | Phase 5 | 2 |
Sophia | Phase 7 | 3 |
Sophia | Phase 8 | 4 |
Annie | Phase 2 | 1 |
Annie | Phase 3 | 2 |
Annie | Pahse 5 | 3 |
Annie | Phase 6 | 4 |
Annie | Phase 7 | 5 |
Annie | phase 8 | 6 |
For each row you have the same employee, it increments the counter by 1. Otherwise, it begins again at 1. I hope i am clear here ;-).
Can someone help me ?
Thanks,
Michael
Solved! Go to Solution.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
@mhendel
Paste the below code in a blank Query in Power Query and check the steps.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc65CoAwEEXRX5GpbdwSLS0sBcEyWAQJJLgFtfHvBUUhM9MeHryrFDSLn7fLGIihs/owMMQKWjf9ECWUMko5JUGppFQ91Olzd+OETrGmrBasvkH95q3TKBxhwaHk8M2v19UZ1BRaFpq2/0u4E4zJwPz3O9w=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Grouped Rows" = Table.Group(#"Promoted Headers", {"Employee"}, {{"Count", each _, type table [Employee=nullable text, Phase=nullable text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([Count], "Counter", 1, 1)),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"Employee", "Phase", "Counter"}, {"Employee", "Phase", "Counter"})
in
#"Expanded Custom"
________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Thanks a lot, you've made my day!!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
100 | |
78 | |
64 | |
58 |
User | Count |
---|---|
148 | |
113 | |
97 | |
84 | |
67 |