Forum Discussion
Dynamic input for filters
- Anonymous4 years ago
Hi tbrown33 ,
I suggest you to use what if parameter to create a slicer.
For reference: Create and use what-if parameters to visualize variables in Power BI Desktop
In my sample I create a 'Past Days' parameter from 1 to 200 and Increment is 1. My data table contains quantities from 2021/01/01 to today. In my example, for ease of calculation, the daily quantity is 1.
Past N days Quantity = VAR _INPUT_DAYS = SELECTEDVALUE ( 'Past Days'[Past Days] ) VAR _QUANTITY = CALCULATE ( SUM ( 'Table'[Quantity] ), FILTER ( 'Table', 'Table'[Date] < TODAY () && 'Table'[Date] >= TODAY () - _INPUT_DAYS ) ) RETURN _QUANTITYResult is as below.
Past 7 days:
Past 180 days:
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi tbrown33 ,
I suggest you to use what if parameter to create a slicer.
For reference: Create and use what-if parameters to visualize variables in Power BI Desktop
In my sample I create a 'Past Days' parameter from 1 to 200 and Increment is 1. My data table contains quantities from 2021/01/01 to today. In my example, for ease of calculation, the daily quantity is 1.
Past N days Quantity =
VAR _INPUT_DAYS =
SELECTEDVALUE ( 'Past Days'[Past Days] )
VAR _QUANTITY =
CALCULATE (
SUM ( 'Table'[Quantity] ),
FILTER (
'Table',
'Table'[Date] < TODAY ()
&& 'Table'[Date]
>= TODAY () - _INPUT_DAYS
)
)
RETURN
_QUANTITY
Result is as below.
Past 7 days:
Past 180 days:
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.