Forum Discussion

wetscott's avatar
wetscott
Icon for Helper I rankHelper I
6 years ago
Solved

Rolling 12 Month Count within a single file, from a folder data source

Dispite trying to follow the various other solutions, nothing seems to work. I believe what I'm trying to do is a little unique compared to previous solutions, hence the new topic.

 

So I've got my report is pulling its data source from a Folder, in that folder I'm dropping a new data file each month, dated with a data date. My query is creating a Reporting Date (EOMONTH -1 of the data date). This combined table is called "Report"

In my report I have a calculated date table (DataDateFilter), that I'm using a the main filter for my report. This has a Dates and MonthYear Column. The dates list is everything between the earliest Reporting Date and the latest.

There's a relationship between 'DataDateFilter'[Date] and 'Report'[Reporting Date].

I've got a few other tables linked to DataDateFilter in the same fashion. The idea is the user can select a MonthYear in the slicer, and the Power BI report will change to reflect the reported data for that month. Like a history roll back function.

I've got a duplicate Date Table using 'Report'[Lodged Date]. The relationship for this one is 'Report'[Lodged Date] to 'AxisDateTable'[Date]. I'm using [MonthYear] on this table on all my axis.

 

What I've got so far is below.

What I need to acheive next, is selecting a date on that filter, needs to only display the 12 months prior to that date on the axis (select Aug 20, you get Jul 19 to Aug 20, and so on)

The bars are I've got right I think. Those are meant to be the counts for each catagory within that month.

The line needs to be the rolling 12 month count of all catagories up until that month (So Aug 20 should be like 101, Jul 20 should be 96, Jun 20 is 69), but within the file of a single data date only. Changing the DataDateFilter to Jul 20, should select all the files for Jul 20, and rolling count will be based on that file only. Selecting Aug 20 on the DataDateFilter, the first month on the axis will by Jul19. Jul19 will be like 75). I tried filtering away prior to the 12 month window for each data file, within the query it's, and that gets the axis right, but then my rolling count line starts at 0 for each period :S

 

Hopefully I'm making sense :S.

I'm abit green with Power BI, and this is doing my head in, because I need to achieve a similar result across like 4 reports I've got to build :S

 

Any help would be greatly appreciated.

 

  • Omg got it! Here's the formula for anyone else that comes across this.

     

    CALCULATE(
    COUNTA('Report'[Notice Number]),
    DATESBETWEEN(
    AxisDateTable[Date],
    SAMEPERIODLASTYEAR(
    LASTDATE(AxisDateTable[Date])
    ),
    LASTDATE(AxisDateTable[Date])
    )
    )

7 Replies