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

Current week and previous week

Hello,

I'm new to power BI and I need to show current week and previous week cases (specifically 10/24/2021 - 10/30/21 and 10/17/2021 - 10/23/2021) with a graph in desktop. I tried a couple of different date tables, but I'm unable to figure it out. The count for the current week cases is 10 and the previous week is 15. The file is .csv. The last case number is 21-0104 and last date is 10/26/2021 for table.

 

@redwood2021

 

Case NumberOpened
21-0018/24/2021 
21-0028/24/2021
21-0038/24/2021
21-0048/26/2021
21-0058/26/2021
21-0068/27/2021
21-0078/30/2021
21-0088/30/2021
21-0098/30/2021
1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @redwood2021 ,

Your picture can't be displayed...

I created some data:

vyangliumsft_0-1635747765650.png

Here are the steps you can follow:

1. Create measure.

Measure =
var _todayweek=WEEKNUM(TODAY())
return
IF(
    WEEKNUM(MAX('Table'[Opened]))>=_todayweek-1&&WEEKNUM(MAX('Table'[Opened]))<=_todayweek,1,0)

2. Put [Measure] into Filter and set is=1.

vyangliumsft_1-1635747765651.png

3. Result:

The data displayed is the current week and last week

vyangliumsft_2-1635747765653.png

 

Best Regards,

Liu Yang

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

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @redwood2021 ,

Your picture can't be displayed...

I created some data:

vyangliumsft_0-1635747765650.png

Here are the steps you can follow:

1. Create measure.

Measure =
var _todayweek=WEEKNUM(TODAY())
return
IF(
    WEEKNUM(MAX('Table'[Opened]))>=_todayweek-1&&WEEKNUM(MAX('Table'[Opened]))<=_todayweek,1,0)

2. Put [Measure] into Filter and set is=1.

vyangliumsft_1-1635747765651.png

3. Result:

The data displayed is the current week and last week

vyangliumsft_2-1635747765653.png

 

Best Regards,

Liu Yang

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

Greg_Deckler
Super User
Super User

@redwood2021 Add a WEEKNUM column and a YEAR column. Then you can do this:

Current Week Cases =
  VAR __Year = MAX('Table'[Year])
  VAR __Weeknum = MAX('Table'[Weeknum])
RETURN
  COUNTROWS(ALL('Table'),[Year]=__Year && [Weeknum]=__Weeknum)

Previous Week Cases =
  VAR __Year = MAX('Table'[Year])
  VAR __Weeknum = MAX('Table'[Weeknum])
RETURN
  COUNTROWS(ALL('Table'),[Year]=__Year && [Weeknum]=__Weeknum-1)

@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Learn Power BI 2nd Edition

@me 

 

I'm receiving error

redwood2021_0-1635391125585.png

Am I putting DAX command in wrong palce?

Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!