Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
I reading several financial PDFs from a folder into power query. The first couple of lines of each PDF has the date the financial statement covers in the first few lines of the PDF header. (From QuickBooks if it maters...)
As you can see if you squint (LOL), the column in the middle has the string "As of" with the date. Futher down the imported data that date of course changes, to another period. AKA the next PDF report.
Before I use row filtering or whatever to remove the report header data I don't need, I would like to use that "As of" string to put together a date column that fills down to subsequent rows. When the power query hits the next "As of" date, fill down using the new date, and so on.
Wondering how one would accomplish this...
Solved! Go to Solution.
Hello,
I would try to add a conditional column that checks if the text contains “As of”, if yes extract the date part, otherwise return null, then use Fill Down on that column so the date propagates until the next “As of” row appears, after that you can filter out the header rows you don’t need and keep the filled date column attached to the data rows.
If the date is embedded in the same column as other text you might need a small Text.AfterDelimiter or similar step to isolate the date first, but the general idea is detect the “As of” rows, create the date, then fill down.
Best regards,
Daniele
Hey, @Dan_at_TWE ,
here's the code for it, copy paste it to blank query and then take the steps:
This will work in your blank query if you copy it 1:1, the first step is just generating the sample data.
let
source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("tZDBCsIwDIZfJfTcQ9YheO12V1BvY4euRBS7Zthu4NurU+eUCbt4CuT7Q36+ohC+dU5IoQPwHtY2ckVnSBMJClV6Az0v5RAcj/tah0AxTIDM+BNoa7n1Y54sEPFx+WSwIUvHzlSO3rEhteNoHHx/UfjiP2rlXDfGX0Bn+WQ3Z7wl2B6I4gT/kLLijureCv7PipplZTnLSnkF", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
replacedValue = Table.ReplaceValue(
source,
"null",
null,
Replacer.ReplaceValue,
{"Column1", "Column2", "Column3"}
),
filledDown = Table.FillDown(
replacedValue,
{"Column2"}
),
custom1 = Table.TransformColumns(
filledDown,
{
{
"Column2",
each Date.From(Text.AfterDelimiter(Text.Lower(_), "as of "), "en-US"),
type date
}
}
)
in
custom1
Hi @Dan_at_TWE ,
Thanks for reaching out to the Microsoft fabric community forum.
I would also take a moment to thank @vojtechsima , for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you .
Best Regards,
Community Support Team
You should be able to use fill down assuming that all other rows in that column are null until the next "as of date". After that, you can replace "As of " with nothing and then you can parse the column as date.
Hello,
I would try to add a conditional column that checks if the text contains “As of”, if yes extract the date part, otherwise return null, then use Fill Down on that column so the date propagates until the next “As of” row appears, after that you can filter out the header rows you don’t need and keep the filled date column attached to the data rows.
If the date is embedded in the same column as other text you might need a small Text.AfterDelimiter or similar step to isolate the date first, but the general idea is detect the “As of” rows, create the date, then fill down.
Best regards,
Daniele
I ended up doing something similar.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 37 | |
| 35 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 74 | |
| 70 | |
| 39 | |
| 35 | |
| 23 |