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

Compare data of one week with the data of the week before, while the date is chosen via slicer

Hi,

 

I've got some Google Searchconsole Data and I want to create a tile that compares the Average Position on a certain date, which is chosen by a slicer, with the Average Position one week earlier. The following just gives me a "(Blank)":

 

AveragePositionOneWeekEarlier = CALCULATE ( [AveragePosition] ; FILTER ( ALL (GSC[Date]) ; WEEKNUM( GSC[Date] ; 21) = [WeekSelected] - 1))

 

I tried inserting an "ALL" after "WEEKNUM":

 

AveragePositionOneWeekEarlier = CALCULATE ( [AveragePosition] ; FILTER ( ALL (GSC[Date]) ; WEEKNUM( ALL (GSC[Date]) ; 21) = [WeekSelected] - 1))

 

but then I just get an error about multiple Values while only one is expected.

 

The Measures used are the following: 

 

Average Position = AVERAGE('GSC'[Position])

WeekSelected = MAX('OtherTable'[Weeknumber])

 

Can someone help me with that?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: Compare data of one week with the data of the week before, while the date is chosen via slicer

@GastroStuermer

 

Since you have date column in your table, you can add WeekNum column and Year column for your calculation.

 

WeekNumber = WEEKNUM('Table'[Date],21)
Year = YEAR('Table'[Date])

Then you can just create two measures to calculate Current Week AVG and Previous Week AVG.

 

 

Current Week AVG = CALCULATE(AVERAGE('Table'[Amount]),FILTER(ALL('Table'),'Table'[WeekNumber]=MAX('Table'[WeekNumber]) && 'Table'[Year]=MAX('Table'[Year]))) 
Previous Week AVG = CALCULATE(AVERAGE('Table'[Amount]),FILTER(ALL('Table'),'Table'[WeekNumber]=MAX('Table'[WeekNumber])-1 && 'Table'[Year]=MAX('Table'[Year]))) 

4.PNG

 

 

Regards,

View solution in original post

2 REPLIES 2
Highlighted
Microsoft
Microsoft

Re: Compare data of one week with the data of the week before, while the date is chosen via slicer

@GastroStuermer

 

Since you have date column in your table, you can add WeekNum column and Year column for your calculation.

 

WeekNumber = WEEKNUM('Table'[Date],21)
Year = YEAR('Table'[Date])

Then you can just create two measures to calculate Current Week AVG and Previous Week AVG.

 

 

Current Week AVG = CALCULATE(AVERAGE('Table'[Amount]),FILTER(ALL('Table'),'Table'[WeekNumber]=MAX('Table'[WeekNumber]) && 'Table'[Year]=MAX('Table'[Year]))) 
Previous Week AVG = CALCULATE(AVERAGE('Table'[Amount]),FILTER(ALL('Table'),'Table'[WeekNumber]=MAX('Table'[WeekNumber])-1 && 'Table'[Year]=MAX('Table'[Year]))) 

4.PNG

 

 

Regards,

View solution in original post

Highlighted
Regular Visitor

Re: Compare data of one week with the data of the week before, while the date is chosen via slicer

HI @v-sihou-msft

 

 

That worked instantly! Thank you! This solution is so elegant and easy 🙂

 

Regards GastroStuermer

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Upcoming Events

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors