Hi all,
I would like to create a new column in a table that will show me number of Master Document for Project Copies.
Example:
Table "Document"
Document Number | Document Category |
61-2300-P-5090 | Master Document |
61-2300-P-5090-07812 | Project Working Copy |
61-2300-P-5090-05908P | Project Working Copy |
61-2300-P-5090-05908T1 | Project Working Copy |
61-2300-P-5090-05908T | Project Working Copy |
61-2300-P-5090-07812-21 | Project Working Copy |
Desired New Column that will identify us the Number of Master Document of this copies:
Document Number | Document Category | New column (Master Documents) |
61-2300-P-5090 | Master Document | 61-2300-P-5090 |
61-2300-P-5090-07812 | Project Working Copy | 61-2300-P-5090 |
61-2300-P-5090-05908P | Project Working Copy | 61-2300-P-5090 |
61-2300-P-5090-05908T1 | Project Working Copy | 61-2300-P-5090 |
61-2300-P-5090-05908T | Project Working Copy | 61-2300-P-5090 |
61-2300-P-5090-07812-21 | Project Working Copy | 61-2300-P-5090 |
One more thing is the lenght of Master Documents can be different and we need to check it by Category.
I tried this code, but it does not work correctly:
Solved! Go to Solution.
I am not sure it will work with your big dataset, but you can try the following in Power Query:
1) Sort your table by "Document Number".
2) Add a conditional column.
3) Apply "Fill Down" form the newly created column.
Best Regards,
Alexander
Hi @barritown ,
Thank you for your solution,
it really works, but I have 2.8 million rows in my table, and now almost 6-7 hours I am waiting for the result, it just stuck on "Working on it"...
Is there any other ways to realise it, maybe in Power query?
Hi @Nurzh,
I knew my solution is greedy in terms of resources, but 6-7 hours - wow.
I will think how to opimize my [DAX] solution - not sure that I will be able to turn hours into minutes, but I'll try. Before that, could you please clarify how many "master" entries you have among those 2.8 million rows?
As for the Power Query solution, maybe it is worth duplicating this post in the "Power Query" section of this forum - I guess Power Query gurus live there. 🙂
Best Regards,
Alexander
Hi @barritown ,
There is approximately 2.7 million of them "Master Documents".
Sure I will try to duplicate post in Power Query section, thank you, hope we can find the best solution 🙂
I am not sure it will work with your big dataset, but you can try the following in Power Query:
1) Sort your table by "Document Number".
2) Add a conditional column.
3) Apply "Fill Down" form the newly created column.
Best Regards,
Alexander
Hi @Nurzh,
Please try this calculated column versus your data:
And in plain text for convenience:
Document Master =
VAR CurrentNumber = [Document Number]
RETURN MINX (
FILTER (
ADDCOLUMNS (
FILTER ( ALL ( Document ), Document[Document Category] = "Master Document" ),
"Match",
VAR CurrentMaster = [Document Number]
RETURN CONTAINSSTRING ( CurrentNumber, CurrentMaster ) ),
[Match] = TRUE () ),
[Document Number] )
Best Regards,
Alexander
Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!