Forum Discussion
Comparing and Calculating Sales for Two Independent Date Periods with Percentage Difference
- 1 year ago
Hi Braytron5
That isn't how crossfiltering works. While you can make a viz crossfilter only a specific viz, you cannot make it partially do so such that only a column or a measure is affected - it either crossfilters or it doesnt at all. In order to make a two-period comparison, you can't be using a range slicer as there aren't two ranges in there - only one - from the start to end date. A way to achieve this is by using a disconnected table for one of the measures. A disconnected date table can be created by referencing the related date table in a calculated table or by creating one in the query editor without relating it to the other fact/dim tables.
In the sceenshot below, Period1 is just a simple as this will be filtered by the related date table.
Sales = SUM ( Sales[Sales Amount] )Period2 is as follows
Sales Period2 = CALCULATE ( [Sales], // Map the selected dates from the DisconnectedDate table to the 'Date' table, maintaining any existing filters on DisconnectedDate[Date]. KEEPFILTERS ( TREATAS ( VALUES ( DisconnectedDate[Date] ), 'Date'[Date] ) ), // Remove any filters applied directly to the 'Date' table to ensure TREATAS controls the filtering. REMOVEFILTERS ( 'Date' ) )Please see sample pbix for the details.
Hi Braytron5 ,
Its not clear for me, sorry.
I mean, the values are equal thats why is returning zero, because you selected the same date range in both slicer's.
Can you explain me more, please?