03-14-2017 04:06 AM - edited 03-14-2017 04:14 AM
Let's start by saying this is my very first post in the forum - I'm very new to Power BI
To give you some background information, we use Fiscal Year with Financial Periods of 4 weeks, 4 weeks, 5 weeks cycles with yearly exceptions where a period which could be period 1 or 12 is a 6 weeks period every few years. Periods start on Sundays and end on Saturdays but (obviously) they don't start on the first day of the month nor they finish on the last date.
I created a CalendarTable as follows to be able to filter data by Year, Fical Period, Quarters, etc:
I have a graph that shows that uses the following data an succesfully filters data using the above table:
I would now like to create a Graph or a table that will display the daily data for LY's period as selected on a slicer, here's an example of part of the graphs currently displayed for Period 6 Year 2013:
So I would like to add to each date a BAR corresponding to each of the dates but for Period 6 in 2012.
Could anyone please shade some light?
03-15-2017 11:46 PM
According to your description above, the total days for different fiscal years may vary, right?
If that is the case, you may need to calculate the total days between the same period last fiscal year and current fiscal year first, then you can use DATEADD function to calculate the daily data for LY's period.
The formula below to create a measure to calculate the daily data for LY's period is for your reference.
LY's Room Sold = VAR currentYear = MAX ( 'Date'[FiscalYear] ) VAR currentPeriod = MAX ( 'Date'[FiscalPeriod] ) VAR daysSinceLY = CALCULATE ( COUNTROWS ( 'Date' ), FILTER ( ALL ( 'Date' ), ( 'Date'[FiscalYear] = currentYear - 1 && 'Date'[FiscalPeriod] >= currentPeriod ) || ( 'Date'[FiscalYear] = currentYear && 'Date'[FiscalPeriod] < currentPeriod ) ) ) RETURN CALCULATE ( SUM ( 'Data'[Room Sold] ), DATEADD ( 'Date'[Date], - daysSinceLY, DAY ) )
03-17-2017 02:56 AM - edited 03-17-2017 04:33 AM
Many thanks for your quick response and suggestion, your solution would be great for to calculate the exact rooms sold for the same number of dates but I need something much simpler which I haven't been able to achieve yet.
All I need is to be able to get the rooms sold for the same period selected in the filter and for the "Previous Year" to the year currently selected in the filter. For example, if currenly my filter is on 2016 & Period 1 I would like to compare to rooms sold for Period 1 2015, regardless of how many weeks the period has in the different years.
03-17-2017 07:26 AM
hi, you can use sameperiodlastyear()
03-17-2017 07:29 AM - edited 03-17-2017 07:30 AM
Thanks for the sugestion but no, I can't use sameperiodlastyear() for fiscal periods as set in my calendar table, I wish it was that easy!
Many thanks anyway.
03-17-2017 08:42 AM
03-17-2017 09:23 AM
Thanks Victor. Rooms Sold for 2007 - P11 should be 1,153. You can see it directly in your table if you change the filter to 2007; your Rooms Sold for 2007 should be the same result as Rooms Sold LY when the filter is on 2008.
03-17-2017 09:30 AM
I have a doubt
In your original post you want to see daily chart (Selected Year and Previous Year of each Day)
The sum by period is not exactly to a last year period because dates are different.
In 2007 period 11 start on 2/9 and in 2008 start in 31/08.