cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Cathe208 Frequent Visitor
Frequent Visitor

Create a visualization that compares 2 weeks: week "x" and "x-1"

I need to create a visualization that compares sales data from week "x" and week "x-1", that is, the week immediately before.

 

Something like this:

Ima.png

 

First, I created a filter per week. then, I was thinking of using cards, in the first card, add the sales of the week "x", in the second card, I should show the sales of the week "x-1". I used the following measure:

 

Sale_sem_bef = CALCULATE(SUM(Sales[COP Value]);FILTER(Calendar;Calendar[Profit_Week]=[filter_sem_bef])).

 

filter_sem_bef = SELECTEDVALUE(Calendar[Profit_Week];1)-1

 

However, the measurement (Sale_sem_bef) is blank.

 

I believe that the week's initial filter is affecting the measurement.

 

How can I solve it? Is there another way to get what I need?

 

Thaks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Nathaniel_C Super Contributor
Super Contributor

Re: Create a visualization that compares 2 weeks: week "x" and "x-1"

Hi @Cathe208 ,

Total Rollover = 
VAR maxDate =
    MAX (m1[Real Date])
VAR Rollover =
    CALCULATE (
        [Sum Excess],
           m1[Real Date]  <= maxDate )
    
RETURN
    Rollover

You will need to do something along these lines to get a previous date or week. In this case, maxDate is set to a the current date, and you filter the table if you use < to the row before this date.  I will provide my pbix and hopefully you can tease out the pattern. Unfortunately I am working on something right now. Rollover or go to https://community.powerbi.com/t5/Community-Blog/Using-EARLIER-with-a-SMART-INDEX/ba-p/809341 and scroll down to the comment by MarcoRusso.  Or finally google dax Previous Row.  You are looking for a pattern.  Good Luck! Nathaniel

View solution in original post

2 REPLIES 2
Nathaniel_C Super Contributor
Super Contributor

Re: Create a visualization that compares 2 weeks: week "x" and "x-1"

Hi @Cathe208 ,

Total Rollover = 
VAR maxDate =
    MAX (m1[Real Date])
VAR Rollover =
    CALCULATE (
        [Sum Excess],
           m1[Real Date]  <= maxDate )
    
RETURN
    Rollover

You will need to do something along these lines to get a previous date or week. In this case, maxDate is set to a the current date, and you filter the table if you use < to the row before this date.  I will provide my pbix and hopefully you can tease out the pattern. Unfortunately I am working on something right now. Rollover or go to https://community.powerbi.com/t5/Community-Blog/Using-EARLIER-with-a-SMART-INDEX/ba-p/809341 and scroll down to the comment by MarcoRusso.  Or finally google dax Previous Row.  You are looking for a pattern.  Good Luck! Nathaniel

View solution in original post

Cathe208 Frequent Visitor
Frequent Visitor

Re: Create a visualization that compares 2 weeks: week "x" and "x-1"

Nathaniel_C Thanks very much for your solution. It worked.

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

New Badges

Incoming: New and Improved Badges

Exciting news: We've given our badges an overhaul and added brand news ones.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 135 members 1,736 guests
Please welcome our newest community members: