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

Compare sales current year with last year for each specific store, if value last year wasn't null.

I want to compare sales current year with last year for each specific store, if value last year for that specific store wasn't null.
For example, if store X on 10 week of 2018 had 0 sales, then don't summarize sales for store X on 10 week of 2019.

I want to separate new stores in current year from old ones by weeks.

At first I need to summarize sales by weeks in 2018 for each store and then compare with sales in 2019.

I tried to get a result using a new table, but in that case I lost the ability to sort sales by date. Can this be done with measures?

Please help me how to do it right?

 

Table = FILTER(
                    ADDCOLUMNS(
                        CROSSJOIN(
                             DISTINCT('Calendar'[Weeknumber]);
                             DISTINCT(Sales[Shop]));
                     "sum2018"; CALCULATE(SUM(Sales[sum]); 'Calendar'[Year] = 2018);
                     "sum2019"; CALCULATE(SUM(Sales[sum]); 'Calendar'[Year] = 2019));
                [sum2018] <> 0)

 

 

New TableNew TableSales TableSales Table

 

1 ACCEPTED SOLUTION

Hello @RomanSk 

Add this measure in which will respect the store / week pairs.

Next Year filtered context = 
SUMX ( SUMMARIZE( sales, Dates[Week], sales[Store] ), [Next Year Filtered] )

View solution in original post

4 REPLIES 4
jdbuchanan71
Super User
Super User

@Hello @RomanSk 

\You should be able to just apply a filter in your calculation of next year so, with these you would select 2018 and the [Next Year Filtered] would be showing 2019.

 

Amount = SUM ( sales[Sales] )
Next Year Filtered = 
IF ( NOT ISBLANK ( [Amount] ), 
CALCULATE([Amount],DATEADD(Dates[Date],+1,year)))

I uploaded a sample file here for you to take a look at.  https://www.dropbox.com/s/egy58koo7ho9s91/FilteredNextYear.pbix?dl=0

filterednextyear.jpg

Thanks for the answer, but here we have a filter context and the totals in measure "Next Year Filtered" are wrong.

Untitled1.png

Hello @RomanSk 

Add this measure in which will respect the store / week pairs.

Next Year filtered context = 
SUMX ( SUMMARIZE( sales, Dates[Week], sales[Store] ), [Next Year Filtered] )

Thank you very much

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.