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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
aashton
Helper V
Helper V

Find count for a week ago, syntax help

So I want to display a list of dates, and what the ticket count was one week before that date.  If it's Sat, Sun or Monday, give me the one week ago from the Friday before.  I've made this date column that works:

 

Week ago exc Weekends = IF('Date'[DayOfWeek]="Sunday", DATEADD('Date'[Date], -9, DAY), IF('Date'[DayOfWeek]="Monday", DATEADD('Date'[Date], -10, DAY), DATEADD('Date'[Date], -8, DAY)))

 

I just can't get the syntax right for the ticket count.    Any syntax I try is not working...

 

I've tried, 

 

Ticket Count Week Ago = CALCULATE([Total Tickets], FILTER('Date', 'Date'[Date]='Date'[Week ago exc Weekends]))

....doesn't work.  Please help.

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @aashton ,

 

It seems that you just want to calculate value of the day that is a week ago, right?

 

I have created a data sample like this:

Date Ticket data sample.PNG

 

Then you could use the following formula to create a column or a measure.

1. Column:

 

Column = CALCULATE(SUM('Date'[Tickets]),FILTER('Date','Date'[Date]=EARLIER('Date'[Week ago exc Weekends])))

 

Or if one day only has one row, you could use LOOKUPVALUE():

 

Column 2 = LOOKUPVALUE('Date'[Tickets],'Date'[Date],[Week ago exc Weekends])

 

 

 2.Measure:

 

Measure(total is wrong) = CALCULATE(SUM('Date'[Tickets]),FILTER(ALL('Date'),'Date'[Date]=MAX('Date'[Week ago exc Weekends])))
Measure = IF(HASONEVALUE('Date'[Date]),[Measure(total is wrong)], SUMX('Date',[Measure(total is wrong)]))

 

The final output is shown below:

Find count for a week ago.PNG

 

Best Regards,
Eyelyn Qin
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

2 REPLIES 2
Anonymous
Not applicable

Hi @aashton ,

 

It seems that you just want to calculate value of the day that is a week ago, right?

 

I have created a data sample like this:

Date Ticket data sample.PNG

 

Then you could use the following formula to create a column or a measure.

1. Column:

 

Column = CALCULATE(SUM('Date'[Tickets]),FILTER('Date','Date'[Date]=EARLIER('Date'[Week ago exc Weekends])))

 

Or if one day only has one row, you could use LOOKUPVALUE():

 

Column 2 = LOOKUPVALUE('Date'[Tickets],'Date'[Date],[Week ago exc Weekends])

 

 

 2.Measure:

 

Measure(total is wrong) = CALCULATE(SUM('Date'[Tickets]),FILTER(ALL('Date'),'Date'[Date]=MAX('Date'[Week ago exc Weekends])))
Measure = IF(HASONEVALUE('Date'[Date]),[Measure(total is wrong)], SUMX('Date',[Measure(total is wrong)]))

 

The final output is shown below:

Find count for a week ago.PNG

 

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

VijayP
Super User
Super User

@aashton  use SELECTEDVALUE(DAY)="Sunday .... so on , it should work. and this data should be in a table visual




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors