Forum Discussion
jdubs
Helper V
6 years agoCreate new calculated table by date range
How do I create a new calculated table and select columns from an existing table while also filtering that data by a date range. Basically I want to create 2 tables of records created in the last...
v-alq-msft
Community Support
6 years agoHi, jdubs
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
If you want to create two calculated columns, you may try the following dax.
Table 1 =
FILTER(
'Table',
YEAR('Table'[Date])=YEAR(TODAY())&&
MONTH('Table'[Date])<MONTH(TODAY())&&
MONTH('Table'[Date])>=MONTH(TODAY())-6
)
Table 2 =
FILTER(
'Table',
YEAR('Table'[Date])=YEAR(TODAY())-1&&
MONTH('Table'[Date])<MONTH(TODAY())&&
MONTH('Table'[Date])>=MONTH(TODAY())-6
)
If you want to create two measures, you may try dax as below.
Count This Year =
COUNTROWS(
FILTER(
ALL('Table'),
YEAR('Table'[Date])=YEAR(TODAY())&&
MONTH('Table'[Date])<MONTH(TODAY())&&
MONTH('Table'[Date])>=MONTH(TODAY())-6
)
)
Count Last Year =
COUNTROWS(
FILTER(
ALL('Table'),
YEAR('Table'[Date])=YEAR(TODAY())-1&&
MONTH('Table'[Date])<MONTH(TODAY())&&
MONTH('Table'[Date])>=MONTH(TODAY())-6
)
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- jdubs6 years ago
Helper V
The is perfect Allan. The only issue is that it gives me to the beginning of February when I need it to stop at Today's date (-6 months) e.g. Feb. 20th. if today is Aug. 20th.
I'm going to do a little research. Let me know if you have any ideas.
Thanks!