Forum Discussion
Using Time Intelligence to calculate Sales in Previous Period
Hi everyone,
I'd like to use the Time Intelligence functionalities in PowerBI Desktop, however they do not work as expected.
The data model is quite simple. I have a table named Sales from excel containing the sales (column Actuals) per product line, country, and month. The month is encoded as first day of the month, e.g. the sales for January 2016 are stored with the date 01.01.2016. The column has data type date.
Further I have a second table named date with columns date (dd.mm.yyyy), year (derived from date with YEAR()). This table has been created in PowerBI directly with the calendar() Function. Both tables are linked via the Date Column
My formula to calculate the sales of the previous month is:
Actuals Prev = CALCULATE(SUM('Sales'[Actuals]); PARALLELPERIOD('Sales'[Date];-1;MONTH))
This works fine so far. However, I'd like to have slighly different behaviour.
In my dashboard I have a slicer on Year, a bar chart showing the actual sales for the selected year per month. In addition to that; i have a matrix, containing the actual sales and the sales of the previous period per product line. In the example below, the slicer is always set to year 2015.
The matrix is changing based on the month that I select in my bar chart, e.g. if I select April 2015, the column actual prev shows the sales for March 2015. However if I select January 2015, I still like to see as actual prev the values for December 2014. This is the first issue that doesn't work.
The second issue is, that I'd like to use the calculation as well in case I select several month, e.g. if I select June & July, my Actual prev should show me the sum of April and May. Further in case I do not select anythink, the Actual prev should show me the sum of the values of 2014.
Any help is appreciated.
Thanks
Andwu wrote:
I do not get your comment "This assumes you are not using any columns from the sales table on your visualization".
Of course I have use some columns from this table, as in this table there are my facts, so I don't get it.
I was refering to the columns slicing your data, not the data itself. If you use a column from your sales table in your slicers, then this will not work.
I just tested this and it works for me.
17 Replies
- MattAllington
Community Champion
You are using he wrong function. swap PARALLELPERIOD with either SAMEPERIODLASTYEAR or DATEADD.
- Andwu
Helper I
Hi matt,
thanks for your reply. I tried that, but that doesn't solve my issues...
Any other ideas?
Thanks
- MattAllington
Community Champion
well it should work, but clearly something is wrong. Any chance you can post a sample (or actual) workbook?