Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi,
I want to create a custom column to count how many times a specic row value occurs in a column.
I dont want to create a calculated column but a custom colum as a transformation step in power query only.
Below is the example of what i am looking for.
Below is how I would do this in excel.
thank you very much
Solved! Go to Solution.
Hi,
Thank you very much for your kind reply.
Pardon me for my follow up, but being not so pro , can I seek your help again on how to add your codes into my existing codes.
Should I just add your code after my last step "
#"Added Index" = Table.AddIndexColumn(#"Merged Columns1", "Index", 1, 1, Int64.Type)
Thanks again
Yes, exactly.
So the end of your code would look like so:
#"Added Index" = Table.AddIndexColumn(#"Merged Columns1", "Index", 1, 1, Int64.Type),
BufferedList = List.Buffer( #"Added Index" [4sector UID]),
AddColumn = Table.AddColumn( #"Added Index" , "Count", each List.Count(List.Select(BufferedList, (l)=> l=[4sector UID])))
in
AddColumn
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi @Learner1585 ,
you can do it like so:
PreviousStepName = <Your existing code here>,
BufferedList = List.Buffer(PreviousStepName[4sector UID]),
AddColumn = Table.AddColumn(PreviousStepName, "Count", each List.Count(List.Select(BufferedList, (l)=> l=[4sector UID])))
For performance reasons, you are adding an intermediate step where you buffer the column that you want to search through in each row.
Then you add the column where you count the values that match the current row.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi,
Thank you very much for your kind reply.
Pardon me for my follow up, but being not so pro , can I seek your help again on how to add your codes into my existing codes.
Should I just add your code after my last step "
#"Added Index" = Table.AddIndexColumn(#"Merged Columns1", "Index", 1, 1, Int64.Type)
Thanks again
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
41 | |
21 | |
20 | |
20 | |
13 |
User | Count |
---|---|
67 | |
53 | |
42 | |
28 | |
22 |