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
jitpbi
Post Patron
Post Patron

current year day to previous year day sales comparison on bar chart

Hi,

 

The below is the sample dataset on which i need to display on 2 visuals

1. last 7 days compariosn of current year sales with the previous year sales

2. Month on month comparison of sales for current year to previous year

 

jitpbi_0-1610625529152.png

jitpbi_1-1610625599268.png

jitpbi_0-1610627377132.png

 

Please suggest how to achieve this.

 

Thanks

 

 

4 REPLIES 4
Fowmy
Super User
Super User

@jitpbi 

If you do not have a date table then you can use the followin as per your sample above:

Last 7 Days Sales = 

CALCULATE(
    SUM('Table'[Sales]),
    FILTER(
        ALL('Table'[Date]),
        'Table'[Date] <= MAX('Table'[Date]) && 'Table'[Date] >= MAX('Table'[Date]) - 7
    )
)
    
Last 7 Days LY Sales = 

CALCULATE(
    SUM('Table'[Sales]),
    FILTER(
        ALL('Table'[Date]),
        var __date = EDATE(MAX('Table'[Date]),-12) return
        'Table'[Date] <= __date  && 'Table'[Date] >= __date - 7
    )
)

 

________________________

If my answer was helpful, please click Accept it as the solution to help other members find it useful

Click on the Thumbs-Up icon if you like this reply 🙂


Website YouTube  LinkedIn

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

@Fowmy ,

 

Thank you for the suggestion. I tried your dax but this is not coming for only 7 days as it shows other day's data also:

 

jitpbi_0-1610629039190.pngjitpbi_1-1610629078571.png

 

thanks

@jitpbi 

I can check how you have applied the formula if you could share a dummy PBIX file with the same setup

 

________________________

If my answer was helpful, please click Accept it as the solution to help other members find it useful

Click on the Thumbs-Up icon if you like this reply 🙂


Website YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

https://www.dropbox.com/s/ajbxf6qjz8p0e5b/test_DOD.pbix?dl=0 Hi @Fowmy ,

 

I am sharing the dropbox link to download the pbix file.

 

Thanks

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.