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.
I have a two columns "JOB" and "ROL", Job is a incremental number and "ROL" this could be "A","B" or "C". And I would like to add a column like index considering how many equals roles there are for each job, as the folowing example:
JOB | ROL | INDEX RESULT |
1 | A | 1 |
1 | A | 2 |
1 | B | 1 |
1 | C | 1 |
2 | A | 1 |
2 | B | 1 |
2 | C | 1 |
3 | A | 1 |
3 | B | 1 |
3 | B | 2 |
3 | B | 3 |
3 | C | 1 |
Hi @abelrmg
You can try something like below.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJUitVBZznBWc5glhFc1gguawSXNYbLGsNlcbGAOmIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [JOB = _t, ROL = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"JOB", Int64.Type}, {"ROL", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"JOB", "ROL"}, {{"Index", each Table.AddIndexColumn( _, "Index", 1 )[Index], type list }}),
#"Expanded Index" = Table.ExpandListColumn(#"Grouped Rows", "Index"),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Index",{{"Index", Int64.Type}})
in
#"Changed Type1"
@abelrmg add an index column in query editor and then add following column and it will get you what you are looking for
Index Result =
RANKX (
FILTER(
What,
What[Job]= EARLIER ( What[Job] ) &&
What[ROL] = EARLIER ( What[ROL] )
),
What[Index], , ASC, Dense
)
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@parry2k , thank you for your suggestion it works, but is there sometihing similar in Power Query?, beacuse then i want to create a pivot table and the values are dynamics and this does not work in DAX.
Regards
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@parry2k It was my mistake, I forgot to mention that I was looking for the solution via Power Query, because then I will use that column to make a pivot table to perform some like this:
Job | ROL A1 | ROL A2 | ROL B1 | ROL B2 | ROL B3 | ROL C1 |
1 | Name 1 | Name 2 | Name 3 | Name 4 | ||
2 | NAME 5 | NAME 6 | NAME 7 | |||
3 | NAME 8 | NAME 9 | NAME 10 | NAME 11 | NAME 12 |
Regards
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 |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
101 | |
86 | |
64 |