Forum Discussion
How to filter with multiple values in multiple columns
- 8 years ago
Hi edhans,
I want Jan 2014 - Sep 2017.
2014, 1-12
2015, 1-12
2016, 1-12
2017, 1-09
You should be able to use the M query below to filter the date column in this scenario. :smileyhappy:
FilterRows = Table.SelectRows(dbo_DimDate, each ([CalendarYear]*12+[MonthNumberOfYear]>=(2014*12+1))and(([CalendarYear]*12+[MonthNumberOfYear]<=(2017*12+9)))) in FilterRowsRegards
why this will not work:
(between 2014 and 2017) and (between 1 and 9) wouldn't work
parry2k wrote:why this will not work:
(between 2014 and 2017) and (between 1 and 9) wouldn't work
Because that will only give me months 1-9 in 2014, 2015, 2016, and 2017.
It will omit months 10-12 in 2014, 2015, and 2016.
I want Jan 2014 - Sep 2017.
2014, 1-12
2015, 1-12
2016, 1-12
2017, 1-09
- v-ljerr-msft8 years agoMicrosoft Employee
Hi edhans,
I want Jan 2014 - Sep 2017.
2014, 1-12
2015, 1-12
2016, 1-12
2017, 1-09
You should be able to use the M query below to filter the date column in this scenario. :smileyhappy:
FilterRows = Table.SelectRows(dbo_DimDate, each ([CalendarYear]*12+[MonthNumberOfYear]>=(2014*12+1))and(([CalendarYear]*12+[MonthNumberOfYear]<=(2017*12+9)))) in FilterRowsRegards
- edhans8 years agoCommunity Champion
This works, and was not entirely sure why until I worked through the logic of it.
So you are just counting months here. 2014 * 12 = 24,168 months since year zero, then adding the months.
Clever.
- edhans8 years agoCommunity Champion
Thank you. Let me give this a shot today.
- parry2k8 years agoSuper User
ok then you have to add custom date column created from year and month and then filter on date from Jan 1, 2014 to Sep 2017.
That is I guess the way to go.