Forum Discussion
Dynamic Date Filter Toggles
i am very new to PBI, coming from a tableau background!
In tableau i could use a parameter field that would have two options: include and exclude
id then create an if condition, if inlcude then one date range, and if exclude then a different date range. I'd be able to add this a sheet filter.
I seem to be hitting a brick wall in delivering this in PBI. any guides/videos/tutorials or work around would be great
info about the data set
Key columns are [order_id], [order_date], [order_date_week]<truncated to monday, [order_date_week_num]
it seems to be failing because i want it as a column but this cant connect to a slicer to create that toggle function... any creative suggestions welcome π
i ended up creating the date/calendar table
then creating this calculated column Is_L5W_Exc & Is_L5W_Inc as below
Is_L5W_Exc =VAR TodayDate = TODAY()VAR StartOfCurrentWeek = TodayDate - WEEKDAY(TodayDate, 2) + 1VAR StartOfPeriod6 = StartOfCurrentWeek - 35RETURNIF(Calendar[Date] >= StartOfPeriod6 &&Calendar[Date] < StartOfCurrentWeek,TRUE(),FALSE())
then in my measures i did*Customer Count Last 5 Weeks =VAR Mode = SELECTEDVALUE('Selector - Timeframe'[Options])RETURNSWITCH(Mode,"Inc", CALCULATE(DISTINCTCOUNT('FACT_CALLS'[UniqueIdentifier]), Calendar[Is_L5W_Inc] = TRUE()),"Exc", CALCULATE(DISTINCTCOUNT('FACT_CALLS'[UniqueIdentifier]), Calendar[Is_L5W_Exc] = TRUE()),BLANK())
11 Replies
- Shahid12523Community Champion
- Create a disconnected table with values like "Include" and "Exclude".
- Use a slicer on that table to let users choose.
- Write a DAX measure that checks the slicer selection and applies different date logic.
- Filter visuals using that measure (e.g., [IsInDateRange] = TRUE).- SaffyNew Member
It wouldn't let me create a measure from a column
- MasonMASuper User
Hi,
After you created a disconnected table with below logic,
Create a Measure, for example with below logic to show Past 3 days 'Request count' when user selects 'Include'.
IsInDateRange = VAR Selection = SELECTEDVALUE('ParameterTable'[Parameter], "Include") RETURN CALCULATE( COUNTROWS('Request'), FILTER( 'Request', IF( Selection = "Include", 'Request'[Created Date] >= TODAY()-3, 'Request'[Created Date] < TODAY()-3 ) ) )
- v-sdhruvCommunity Support
Hi Saffy ,
In each visual (e.g., net sales, margin, etc.), add a filter: IsInDateRange= True
This way, the visual only shows data based on the selected toggle.
You donβt need to recreate this for every metric. Just use this IsInDateRange measure as a filter across visuals. Your actual metrics (like Net Sales, Margin, etc.) stay untouched.
Regards,
Shruti - SaffyNew Member
ok my table is called sales
IsInDateRange =VAR Selection = SELECTEDVALUE('Include/Exclude'[Parameter], "Include")RETURNCALCULATE(COUNTROWS('Sales'),FILTER('Sales',IF(Selection = "Include",'Sales'[order_date] >= TODAY()-3,'Sales'[order_date] < TODAY()-3)))
so i've updated the formula and created it as a measure, but when i drag it onto a visual what do i filter these are the options
- v-sdhruvCommunity Support
Hi Saffy ,
Just wanted to check if the above suggestion has addressed your query.
If you are still facing any issues you can reach out with sample data (excluding sensitive data) and share excatly where you are having difficulty so that we can assit you better.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community
Thank You- SaffyNew Member
i ended up creating the date/calendar table
then creating this calculated column Is_L5W_Exc & Is_L5W_Inc as below
Is_L5W_Exc =VAR TodayDate = TODAY()VAR StartOfCurrentWeek = TodayDate - WEEKDAY(TodayDate, 2) + 1VAR StartOfPeriod6 = StartOfCurrentWeek - 35RETURNIF(Calendar[Date] >= StartOfPeriod6 &&Calendar[Date] < StartOfCurrentWeek,TRUE(),FALSE())
then in my measures i did*Customer Count Last 5 Weeks =VAR Mode = SELECTEDVALUE('Selector - Timeframe'[Options])RETURNSWITCH(Mode,"Inc", CALCULATE(DISTINCTCOUNT('FACT_CALLS'[UniqueIdentifier]), Calendar[Is_L5W_Inc] = TRUE()),"Exc", CALCULATE(DISTINCTCOUNT('FACT_CALLS'[UniqueIdentifier]), Calendar[Is_L5W_Exc] = TRUE()),BLANK())