Forum Discussion
pradeepyadav921
2 years agoFrequent Visitor
Finding two previous dates with current date
Hi everyone, I have a dataset where I have a product and date now I have created a date picker now how to get previous two dates, as my final aim is to show the product and their data for the dat...
- 2 years ago
We can do this by using the DAX measure. Please refer to the measure and screenshot for your reference.
1. Total Sales = SUM('Table (2)'[Sales])2. Total Sales Today and Previous 2 Days =VAR SelectedDate = SELECTEDVALUE('Table'[Date])RETURNIF(ISFILTERED('Table'[Date]),CALCULATE([Total Sales],FILTER(ALL('Table'),'Table'[Date] >= SelectedDate - 2 && 'Table'[Date] <= SelectedDate)),[Total Sales])The selected date in the filter is 5/4/2023 it shows values for the selected and last 2 days.
Did I answer your question? Mark my post as a solution! This will help others
Thanks,
Hari R
Shreeram04
2 years agoResolver III
We can do this by using the DAX measure. Please refer to the measure and screenshot for your reference.
1. Total Sales = SUM('Table (2)'[Sales])
2. Total Sales Today and Previous 2 Days =
VAR SelectedDate = SELECTEDVALUE('Table'[Date])
RETURN
IF(
ISFILTERED('Table'[Date]),
CALCULATE(
[Total Sales],
FILTER(
ALL('Table'),
'Table'[Date] >= SelectedDate - 2 && 'Table'[Date] <= SelectedDate
)
),
[Total Sales]
)
The selected date in the filter is 5/4/2023 it shows values for the selected and last 2 days.
Did I answer your question? Mark my post as a solution! This will help others
Thanks,
Hari R