Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Static Previous weeks Counts

I have sample data with item number and closing date in it. I am trying to display previous week (week start from Sunday) item counts always. I try to use filter function comparing current week-1 option but not getting right result. Please help us how do I achieve this. the filter condition I am using calculate (countdistinct [ItemNumber], Filter (table, weeknum([CloseDate],2)=weeknum(Today(),2)-1)). Below the sample data. Ideally I wanted to show previous week (04/18 04/24)to Item Number count (should be 30)

 

ITEM NumberClose Date
106582224/29/2021
106625654/28/2021
106619894/28/2021
106622484/28/2021
106606894/28/2021
106594594/28/2021
106670394/28/2021
106669684/28/2021
106666334/28/2021
106372154/27/2021
106431994/27/2021
106539924/27/2021
106347454/27/2021
106431434/26/2021
106517694/26/2021
106624194/26/2021
106391984/26/2021
106589734/26/2021
106472334/26/2021
106451404/26/2021
106369814/26/2021
106581524/23/2021
106563394/23/2021
106299744/23/2021
106266264/23/2021
106418594/22/2021
106260164/22/2021
106545864/22/2021
106607184/22/2021
106013664/22/2021
105644234/22/2021
106355354/22/2021
106532404/22/2021
106534644/21/2021
106427634/21/2021
106401494/21/2021
106453274/21/2021
106266344/21/2021
106611074/21/2021
106539844/21/2021
106592734/21/2021
106604624/21/2021
106582054/21/2021
106543224/21/2021
106587734/20/2021
106514934/20/2021
106495804/20/2021
106564054/20/2021
106576844/19/2021
106580304/19/2021
106587874/19/2021
106572004/16/2021
106482124/16/2021
106415954/15/2021
106228054/15/2021
106417004/14/2021
105434144/14/2021
106537864/14/2021
106541804/14/2021
106536514/13/2021
106142254/13/2021
106530794/13/2021
106413184/13/2021
106460804/13/2021
106433674/12/2021
106504544/12/2021
106523384/12/2021
106523114/12/2021
106241874/12/2021
106465174/12/2021
106242344/12/2021
106355404/12/2021
106515624/12/2021
106394604/12/2021
106506804/9/2021
106506874/9/2021
106506844/9/2021
106490204/9/2021
106202554/9/2021
106464544/9/2021
106472884/9/2021
106481504/9/2021
106480864/9/2021
106502724/9/2021
106502194/9/2021
106501944/9/2021
106501724/9/2021
106501514/9/2021
106493394/8/2021
106409244/8/2021
106145514/8/2021
106493154/8/2021
106452054/8/2021
106468394/7/2021
106429574/7/2021
106237284/7/2021
106457414/7/2021
106266034/6/2021
106427234/6/2021
106427084/6/2021
106418494/6/2021
106418094/6/2021
106454744/6/2021
106454044/6/2021
106044764/5/2021
106145594/5/2021
105587864/2/2021
106428614/2/2021
106228034/2/2021
106227994/2/2021
106227964/2/2021
106412314/2/2021
106227374/2/2021
106429804/2/2021
106443174/2/2021
106442384/2/2021
106439234/1/2021
106330064/1/2021
106029494/1/2021
105833154/1/2021
106309664/1/2021
106172224/1/2021
106434274/1/2021
106430654/1/2021
106092514/1/2021
106056564/1/2021
105971634/1/2021
106430234/1/2021
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please try the below.

 

Picture5.png

 

Item count previous week =
CALCULATE (
DISTINCTCOUNT ( [ITEM Number] ),
FILTER (
'Table',
WEEKNUM ( 'Table'[Close Date], 1 )
= WEEKNUM ( TODAY (), 1 ) - 1
)
)
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

6 REPLIES 6
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please try the below.

 

Picture5.png

 

Item count previous week =
CALCULATE (
DISTINCTCOUNT ( [ITEM Number] ),
FILTER (
'Table',
WEEKNUM ( 'Table'[Close Date], 1 )
= WEEKNUM ( TODAY (), 1 ) - 1
)
)
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Anonymous
Not applicable

Thanks Kim, can we add additional filter conditions this tis like current year because in my data set I have five years of data so the calculation shared accumulating all the values relavence to that week from all the months but we are expecting latest year only. 

Hi, @Anonymous 

Thank you for your message.

Please try something like the below, that one more condition is added.

 

Item count previous week =
VAR currentyear =
YEAR ( TODAY () )
RETURN
CALCULATE (
DISTINCTCOUNT ( [ITEM Number] ),
FILTER (
'Table',
WEEKNUM ( 'Table'[Close Date], 1 )
= WEEKNUM ( TODAY (), 1 ) - 1
&& YEAR ( 'Table'[Close Date] ) = currentyear
)
)

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Anonymous
Not applicable

It is working now, thanks for the help. 

Anonymous
Not applicable

I did tied that but it was retruning below error 

A function 'FILTER' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

sayaliredij
Super User
Super User

Hi 

I think your formula is generating 30

sayaliredij_0-1619726913392.png

 

Regards,

Sayali

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.