Forum Discussion
Display data for previous 6 months
Hello,
I have a fact table and a dimension date table related with each other through the date columns (Date - Created_On). I have to filter the month in slicer and to display the number of applications for the last 6 month excluding the selected month. And the average of applications for the last 6 months excluding the selected month.
I have tried this formula.
Thanks in advance!
| FactTable | |
| Original_Id | Created on |
| 1 | 1/2/2021 |
| 2 | 1/3/2021 |
| 3 | 1/4/2021 |
| 4 | 1/5/2021 |
| Dimdate | ||
| Year | Month | Date |
| 2021 | Jan | 1/2/2021 |
| 2022 | Feb | 1/2/2022 |
| 2021 | Mar | 1/3/2021 |
| 2021 | Apr | 1/4/2021 |
Anonymous , If you want to select a month and want to show more than that on the axis/row, the slicer needs to be on an independent date table
//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = eomonth(_max, -6) +1
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI
- Anonymous4 years ago
HI amitchandak
It helped me a lot a formula used in the video you shared.
Nr of app in the last 6 months=CALCULATE ( DISTINCTCOUNT(FactTable[Original_ID]),DATESINPERIOD (DimDate[Date],EOMONTH( MAX ( DimDate[Date]),-1), -6,MONTH))
7 Replies
- amitchandak
Super User
Anonymous , If you want to select a month and want to show more than that on the axis/row, the slicer needs to be on an independent date table
//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = eomonth(_max, -6) +1
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI
- AnonymousNot applicable
HI amitchandak
The problem is that in the same report I have to display different data (measures) for the selected months, for previous month and the last 6 months excluding the selected one, in order to compare the data. So the slicer should be the one from DimDate table. - AnonymousNot applicable
HI amitchandak
It helped me a lot a formula used in the video you shared.
Nr of app in the last 6 months=CALCULATE ( DISTINCTCOUNT(FactTable[Original_ID]),DATESINPERIOD (DimDate[Date],EOMONTH( MAX ( DimDate[Date]),-1), -6,MONTH))
- tamerj1
Community Champion
Hi Anonymous
Please refer to this sample file based on sales table. However, you can follow the same method but replace with the desired aggregation.- AnonymousNot applicable
The Year Month in slicer is from the Date table?
- tamerj1
Community Champion
Anonymous
Yes. But in the table visual itself you are slicing by the PreviousDate table.