Forum Discussion
Filter Date Range using IF condition
Hi all,
Is there any way we can restrict the dates from the Date Column in my data based on the conditions i.e., by using IF condition?
If yes, please provide me the DAX syntax.
A small illustration like:
IF(a>b, Dates> x && Dates <y)
Thanks in advance 🙂
Kashyap.
3 Replies
- amitchandakSuper User
If you want to use in If and in the measure then you need use some aggregation
IF(a>b, Max(Dates)> x && max(Dates) <y)
if you in the filter you can avoid max on a date if X and Y are static
What you have done is possible in the column
refer example on my blog
- AnonymousNot applicable
Thanks for the response amitchandak
Also, I have a table visual on which I need to filter a specific range of dates based on the selection in another date slicer, how can we do it?
I have my main table(T1) with columns including Date column, I created a duplicate of the T1 as T2 and removed every column except Date column. So when I select a value from the date column in T2, I need to get the data from the SelectedDate till SelectedDate-30 in a table visual which contains the columns from T1.
How can we achieve this ?Thanks
Kashyap.- v-lili6-msftCommunity Support
hi Anonymous
When you create a measure add this conditional in the formula as below:
eg.
Measure = CALCULATE(SUM('Table 1'[value]),FILTER('Table 1','Table 1'[Date]>=MAX('Table 2'[Date])-30&&'Table 1'[Date]<=MAX('Table 2'[Date])))In this simple sample, I will show the data from the SelectedDate till SelectedDate-7and here is sample pbix file, please try it.Regards,lin