Forum Discussion
Filter using custom date options
Hi Mark,
It seems the measure worked. What's the issue? Do you mean the table visual should only show two rows and hide the other rows?
Best Regards,
Dale
Hi Dale,
Thanks for taking a look and yes that is correct, I want the table to be filted to those two rows, thereby also filtering my main data table which is joined to the date table, to only return data for those two dates.
Perhaps using this method is not viable?
Thanks
Mark
- v-jiascu-msft8 years agoMicrosoft Employee
Hi Mark,
That's because there are many other columns. Maybe you can use the filters.
Best Regards,
Dale
- MarkSL8 years agoHelper V
Hi Dale,
No that doesn't change it and I think I may have confused things. Let me try to simplify my query...
I want to offer the users a filter on date. I don't want to use the Relative Date Slicer as it offers options which are not suitable for my need. I therefore want to offer the user a specific list of date options which will be applied to the date column SalesDate in my main sales table:
So I essentially need a method of saying..
If Category = "Today", then filter SalesDate = TODAY()
If Category = "Yesterday", then filter SalesDate = TODAY()-1
etc.
Thanks
Mark
- v-jiascu-msft8 years agoMicrosoft Employee
Hi Mark,
Maybe you need a measure like this.
Measure = IF ( HASONEVALUE ( 'DateOptions'[Category] ), SWITCH ( MIN ( 'DateOptions'[Category] ), "Today", CALCULATE ( SUM ( 'Table'[Value] ), 'DateControl'[Date] = TODAY () ), "Yesterday", CALCULATE ( SUM ( 'Table'[Value] ), 'DateControl'[Date] = TODAY () - 1 ), "This Year", CALCULATE ( SUM ( 'Table'[Value] ), YEAR ( 'DateControl'[Date] ) = YEAR ( TODAY () ) ), "This Week", CALCULATE ( SUM ( 'Table'[Value] ), FORMAT ( 'DateControl'[Date], "YYYYww" ) = FORMAT ( TODAY (), "YYYYww" ) ), "This Month", CALCULATE ( SUM ( 'Table'[Value] ), DATESINPERIOD ( 'DateControl'[Date], EOMONTH ( TODAY (), 0 ), 1, MONTH ) ), "Last Week", CALCULATE ( SUM ( 'Table'[Value] ), INT ( FORMAT ( 'DateControl'[Date], "YYYYww" ) ) = FORMAT ( TODAY (), "YYYYww" ) - 1 ), 0 ) )Best Regards,
Dale