Latest Enterprise DNA Initiatives

PowerQuery to extract time series data for lookup tables

Hi All,
I have a PowerQuery questions I am hoping you can assist with. I have done some extensive research but cannot find an appropriate solution.

I have a dimension table that is time series and I want to use this table, based on the date to extract comparative lookup tables (i.e. Prior Qtr, Same Qtr Last year, Prior Yr End). The comparative dates could be linked to a current Quarter Parameter or be a new one.

Based on a reference date, (I.e. Quarter end date), I want to be able to add a calculated column that identifies which row is included for said date. This would include current product names and those which were previously discontinued. For discontinued products, I would expect to see the last submission based on the reference date.

I have preferenced doing this in the query editor so these can be unique tables that populate into the model although am open to suggestions as to best practice to achieve this.

I have attached a sample data set with a table you can import, and included explanations and expected outputs in the lookup tables.

Please let me know if you need more information or if I can be clearer.


PowerQuery Time Series Example Data.xlsx (12.1 KB)

Hi @123kerrod, Welcome to the forum, we aim to consistently improve the topics being posted on the forum to help you in getting a strong solution faster. While waiting for a response, here are some tips so you can get the most out of the forum and other Enterprise DNA resources.

  • Use the forum search to discover if your query has been asked before by another member.

  • When posting a topic with formula make sure that it is correctly formatted to preformated text </>.

  • Use the proper category that best describes your topic

  • Provide as much context to a question as possible.

  • Include demo pbix file, images of the entire scenario you are dealing with, screenshot of the data model, details of how you want to visualize a result, and any other supporting links and details.

I also suggest that you check the forum guideline How To Use The Enterprise DNA Support Forum. Not adhering to it may sometimes cause delay in getting an answer.

Hi @123kerrod

I’ve had a look at your sample data. It’s my understanding that you want to use the list of products and dates to create new period tables that list the products within that period.

If so, then in PQ you’ll need to create a new query for each period table you need and use relative date filtering to return only the data you need. You’ll need the formula bar enabled though.

i.e. This will give you today a year ago, which could be used as a filter input.

Date.AddYears( Date.From( DateTime.LocalNow() ), -1 )

Hi @123kerrod, we’ve noticed that no response has been received from you since the 9th of June. We just want to check if you still need further help with this post? In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the checkbox. Thanks!

Thanks for looking at this!

Yes that is part of it, however it needs to be able to handle where a product is not listed in the date filtered and bring in the last entry before that time. In excel, this would be something along the lines of large() from the dates up to the filtered date.