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

Compare previous and new sales

Hi All

 

Im trying in Power BI to create a report with yesterdays sales compared to the same day last year.

 

I managed to make a report showing the sale from day this year and the sale from the same day last year.

I got them sorted by our stores. Så i have the stores in rows and the 2 dates in the columns with their sales. Now i want a third column with the difference between the 2 numbers, and i cant figure out how to do that - everything i have tried that gets remotely close to what i want to achieve makes an column with a difference after the 2015 date and the 2016 date - i only want a single column at the end showing the difference.

 

STORE-->SALES YESTERDAY-->SALES SAME DAY LAST YEAR-->DIFFERENCE BETWEEN

 

I tried searching for a solution but cant find one that comes close enough to what i want to achieve.

 

Hope somebody can help.

2 REPLIES 2
v-sihou-msft
Employee
Employee

@diddlmus

 

Generally, we can make the dataset with columns of Date, Store and Sales as below.

Then we can create a calculated column “Diff_PY_Sales” with following formula to get the difference of sales between day this year and the same day last year.

 

Diff_PY_Sales =
VAR PY_Sales =
    CALCULATE (
        SUM ( Table1[Sales] ),
        SAMEPERIODLASTYEAR ( Table1[Date] ),
        ALLEXCEPT ( Table1, Table1[Store] )
    )
RETURN
    (
        IF (
            SAMEPERIODLASTYEAR ( Table1[Date] ) <> BLANK (),
            Table1[Sales] - PY_Sales,
            BLANK ()
        )
)

48.png

 

Regards,

Vvelarde
Community Champion
Community Champion

 



Lima - Peru

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.