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
ngocrin1
Frequent Visitor

Create a virtual table with Previous date transaction column

Hi everyone,

I have problem with creating a Virtual table with Previous date transaction column. Has everyone can help me?

The formula to get the Previous date column is below:

 

 formula.png

But the result is still blank.

result.png

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @ngocrin1 
Actually I did not get the idea of using 'Date'[Date] to obtain the previous date. If you want to get pervious calendar date then simply use

Virtual Table =
ADDCOLUMNS (
    SUMMARIZE ( Sales, Sales[Purchase Date], Sales[Sales Person ID] ),
    "@Revenue", [Sales Revenue],
    "@PreDate", Sales[Purchase Date] - 1
)

If you're looking for the previous sales date of the product in row then please try

Virtual Table =
ADDCOLUMNS (
    SUMMARIZE ( Sales, Sales[Purchase Date], Sales[Sales Person ID] ),
    "@Revenue", [Sales Revenue],
    "@PreDate",
        VAR CurrentDate = Sales[Purchase Date]
        VAR PreDate =
            MAXX (
                CALCULATETABLE (
                    VALUES ( Sales[Purchase Date] ),
                    Sales[Purchase Date] < CurrentDate
                ),
                Sales[Purchase Date]
            )
        RETURN
            PreDate
)

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

Hi @ngocrin1 
Actually I did not get the idea of using 'Date'[Date] to obtain the previous date. If you want to get pervious calendar date then simply use

Virtual Table =
ADDCOLUMNS (
    SUMMARIZE ( Sales, Sales[Purchase Date], Sales[Sales Person ID] ),
    "@Revenue", [Sales Revenue],
    "@PreDate", Sales[Purchase Date] - 1
)

If you're looking for the previous sales date of the product in row then please try

Virtual Table =
ADDCOLUMNS (
    SUMMARIZE ( Sales, Sales[Purchase Date], Sales[Sales Person ID] ),
    "@Revenue", [Sales Revenue],
    "@PreDate",
        VAR CurrentDate = Sales[Purchase Date]
        VAR PreDate =
            MAXX (
                CALCULATETABLE (
                    VALUES ( Sales[Purchase Date] ),
                    Sales[Purchase Date] < CurrentDate
                ),
                Sales[Purchase Date]
            )
        RETURN
            PreDate
)

Tks Tamerj1,

It worked well. I'm looking for previous date sales transactions.

some_bih
Super User
Super User

Hi @ngocrin1 please try to change your date column in Power Query from type date time to type date, and see results. I hope this help





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






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.