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

Filter by week And Last Week

Hello,

 

I'm trying to create a graph that shows a recent tendency. I must be able to filter it by week and year. But also, i would like to see the last week result so i may observe a tendency.

 

In resume, i have a graph and two filters (year and week). I must show on graph 3 numbers: (acumulated result of selected year - wich is ok; result of selected week - wich is also ok; and result of the previous selected week - wich is my doubt). I would like to do that in a way a could easily filter weeks and years using a filter outside the graph/formula.

 

Could any one help me?

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Filter by week And Last Week

Hi @htittoto ,

 

The dark blue curve’s formula like this,

 

last_week = 
var last_w = MAX('Table'[week])-1
return
CALCULATE(SUM('Table'[values]),FILTER(ALLSELECTED('Table'),'Table'[week]=last_w))

 

Filter 1.jpg

 

If you have any questions, please kindly ask here and we will try to resolve it.

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Highlighted
Community Support
Community Support

Re: Filter by week And Last Week

Hi @htittoto ,

 

We can use the following steps to meet your requirement.

 

1. Create year column and week column.

 

year = YEAR('Table'[Date])

 

week = WEEKNUM('Table'[Date])

 

Filter 1.jpg

 

2. Then we can create a measure. And add two slicers, one is week, another is year. The result like this,

 

Filter 2.jpg

 

Filter 3.jpg

 

If it doesn’t meet your requirement, could you please provide a mockup sample  based on fake data or describe the fields of each tables and the relations between tables simply?

 

It will be helpful if you can show us the exact expected result based on the tables.

 

Please upload your sample files to OneDrive For Business and share the link here and don't contain any Confidential Information or Real data in your reply.     

 

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
Regular Visitor

Re: Filter by week And Last Week

@v-zhenbw-msft, first thanks for replying.

 

I've done everything the same way you did. The only thing i couldn't do was the last week curve. How did you build the formula for the dark blue curve (in the images you've sent)? That is the only thing i couldnt do. What is the formula?

 

Thanks,

Highlighted
Community Support
Community Support

Re: Filter by week And Last Week

Hi @htittoto ,

 

The dark blue curve’s formula like this,

 

last_week = 
var last_w = MAX('Table'[week])-1
return
CALCULATE(SUM('Table'[values]),FILTER(ALLSELECTED('Table'),'Table'[week]=last_w))

 

Filter 1.jpg

 

If you have any questions, please kindly ask here and we will try to resolve it.

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Regular Visitor

Re: Filter by week And Last Week

@v-zhenbw-msft @Thanks for the answer, it has worked perfectly! 

Helpful resources

Announcements
June 2020 Community Highlights

June 2020 Community Highlights

Featured community members, changes to the Community, and more! Read up on recent Power BI community news.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors