Last Twelve months when you have no data in a period

Hi all,

I am back looking for some more help.
I am building a BI model that will load in 100+ companies financial statements.
As in my last post I am loading up the data in the format of the attached file. In this file I categorise items as annual data or interim data (in this example quarterly).

A key items is to be able to show the trailing 12 months figures aside of the annual figures.
I wrote this formula which I thought was great - it allowed for annual data when the interim is 0 (I only start interim data from 2015 but have annual until 2010)

image

This works perfectly in the single airline situation (note the last date in my date table is dynamic using the list.max query which is linked to the the financial data table).

But what struck me is if I load in 100 airlines, the max date in the date table will be the latest date of the most recent airline that reports. Fore example if Delta Air Lines has reported financial data for 31 Dec 2021 while Aegean Airlines has only reported up to 30 Sept 2021, the date table max date will be 31 Dec 2021 aligned to the max date in the financial data.

This creates a second round impact, because if I am looking at Aegean airlines the formula I wrote looks for the max date (31 Dec 2021 - due to Delta figures) and sums up the last 4 quarters. In the case of Aegean (the airline I am trying to filter) it would sum up all of 2021 but Q4 will be blank and it will give me only the 3 quarter of 2021 that have data for Aegean and not the last 12 months or last 4 quarters that I actually have data for this airline.

In summary I need to find a way to say max date is the most recent date that has data associated with the carrier that I am selecting. But this is where I am struggling to figure out what my maxdate Var should be so that it will only ever take the last date that there is data for Aegean and not just the last date in the total date table.

As ever all and any insight or help would be greatly appreciated.

Please note that in the BI model attached the last date on the date table is manually put in as 1/1/2023 as I was testing the concept I outlined above.
Airline Financial and Operational BI Model.pbix (1.3 MB)
Airline Financial and Operational Datasets.xlsx (136.2 KB)
Airline Master Sheet.xlsx (28.5 KB)

One of the items I wanted
*** READ FIRST ***

Before you send your question.
Make sure that all details relevant to your question is complete:

  • Your current work-in-progress PBIX file - VERY IMPORTANT
  • A clear explanation of the problem you are experiencing
  • A mockup of the results you want to achieve
  • Your underlying data file

Check out this thread on Tools and Techniques for Providing PBIX Files with Your Forum Questions
Also make sure that your data file contains no confidential information. If it does, click the link above.

*** DELETE THIS MESSAGE IF YOU ARE SURE ALL YOUR DETAILS ARE COMPLETE OR IF THE ABOVE INFORMATION IS NOT APPLICABLE TO YOUR QUESTION.***

@Ronan ,

If I’m understanding the issue at hand here correctly, I think it can be addressed quite simply in PQ by the very powerful AllRows/Group By combination. Here’s how I would set it up:

In the fact table data you’ve provided, it looks like that only includes Airline Code 2, so the output from this is not that interesting, but this will return the max date for each airline in a new column called MaxDate in the table.

Here’s a video I did a while back explaining exactly how to handle these types of grouping challenges in PQ:

Much simpler than doing this via DAX IMO, and make sense since these dates are not going to be dynamic within the course of a single reporting session, so they should be pushed further “upstream” of DAX into PQ or even your data warehouse if available.

I hope this is helpful.

  • Brian

Hello @Ronan, it’s been a while since we got a response from you.

Just following up if you still need help with your inquiry?

If you do, kindly provide the information the experts requested above so they can help you further.

In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved.

Hi @Ronan, due to inactivity, a response on this post has been tagged as “Solution”. If you have any concern related to this topic, you can create a new thread.

Dear Brian,

Sincere apologies for not replying sooner. Thank you kindly for sending a solution. I will work through this and see if I can figure it out.

1 Like

@Ronan,

Glad to help. Feel free to give a shout if you have any questions while working through the solution.

  • Brian
1 Like

Yes I suspect I might need some help alright. As you noted only one airline code is there as I am trying to get this right with one airline data set before I go full steam on all airlines I have

Brian as a follow up the issue seems to be that this groups or aggregates my financial data table to just one row being the last date but then it seems to mess up the model

image

I think I need to keep that table with all the data as this is where I run the measures from and this is my core fact table. DO you think I am missing something here?