Forum Discussion
Set FILTER value with variable
- 10 years ago
Hi,
I assume your Transactions table is like below.
In DAX, we can’t define a variable for user selection and use it in calculation. You should use slicer to achieve your goal. In your scenario, I think you want to calculate the cumulative total amount. You need to use ALL() function to ignore the current row slicing.
Your measure should be like:
Measure = CALCULATE(sum(Transactions[Amount]), FILTER(ALL(Transactions), Transactions[Transaction Date] <MAX(Transactions[Transaction Date])))
Now we can create a slicer to show this measure. I think you don’t want to have the slicer selection affect visual. You can “Edit Interactions” and select “None” on visual.
And when you show this measure to whole table, you can see that:
Best Regards
Alex
Hi,
I assume your Transactions table is like below.
In DAX, we can’t define a variable for user selection and use it in calculation. You should use slicer to achieve your goal. In your scenario, I think you want to calculate the cumulative total amount. You need to use ALL() function to ignore the current row slicing.
Your measure should be like:
Measure = CALCULATE(sum(Transactions[Amount]), FILTER(ALL(Transactions), Transactions[Transaction Date] <MAX(Transactions[Transaction Date])))
Now we can create a slicer to show this measure. I think you don’t want to have the slicer selection affect visual. You can “Edit Interactions” and select “None” on visual.
And when you show this measure to whole table, you can see that:
Best Regards
Alex
Thank You, Alex. This works for me.