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,
Hope you can help with this.
I have a table that looks like this:
Transaction ID | Extracts |
1 | 021, 003, 022, 603, 415 |
2 | 002, 001, 408, 510 |
3 | 005, 004, 006, 510, 415, 408 |
From the Extracts column, I care about the last number (to the right) if its one of the following: 001, 002, 003, 004, 005, 006. All the other ones are irrelevant.
So at the end, for Transcation ID 1, the number I would need is 003.
For Transcation ID 2, 001.
For Transcation ID 3, 006.
The order of the number is very important and need to be mantained. And as you can see, there is no easy way to predict how many each Transaction ID will have. It could be 5, 1 or even up to 10.
Thanks you!
Solved! Go to Solution.
Hi @NPC,
You can extract these specific numbers from a group by using list functions.
Create a custom column using this M Code:
Extract = List.Last(List.Select(Text.Split([Extracts],","), each _ <= "006"))
This code will:
In case you don't have any number from 001 to 006 in your group, you'll get a null value.
Works for you? Mark this post as a solution if it does!
I'll remove the square brackets and see what happens. Thanks!
Let me know if that works or not...
The square brackets were causing issues. Thank you so much!
Hi @NPC,
You can extract these specific numbers from a group by using list functions.
Create a custom column using this M Code:
Extract = List.Last(List.Select(Text.Split([Extracts],","), each _ <= "006"))
This code will:
In case you don't have any number from 001 to 006 in your group, you'll get a null value.
Works for you? Mark this post as a solution if it does!
@Shaurya Thank you! It works it some cases but not in all for some reason. As you can see below, instead of pulling 004, it pulled 209. Any thoughts as to why that's happening? The new column I created is " Exracted Latest Scenarion". Ignore the date column.
Thanks!
Hi @NPC,
I think this is because of the square brackets. The original column in your post had only comma separated values. However in the second case where you got the wrong output, the values are separated by comma but also enclosed in brackets. Can you check if you get any wrong values at all in the first case?
As far as the second case is concerned, if you can specify the different ways in which the Extract column may have values, we can work out a solution that gives the right values in all cases.
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 |
---|---|
114 | |
99 | |
83 | |
70 | |
60 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |