Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pradeepyadav921
Frequent 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 date I selected from the date picker and previous two dates also in a tabular format.

 

 

1 ACCEPTED SOLUTION
Shreeram04
Resolver III
Resolver III

Hi @pradeepyadav921 

 

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]
)

Shreeram04_0-1711813742304.png

Shreeram04_1-1711813871241.png

 

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

 

 

 

View solution in original post

1 REPLY 1
Shreeram04
Resolver III
Resolver III

Hi @pradeepyadav921 

 

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]
)

Shreeram04_0-1711813742304.png

Shreeram04_1-1711813871241.png

 

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

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.