Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Is it possible to use an if statement in set analysis?

Hello,

I'm using set analysis to get the number of sold items for a specific week (this week).

I'm using

sum({$ <YEAR = {"=year(today())"}, WEEK = {"=week(today())"}>}Sold)

What I get is the sum for all weeks this year.

I suspect the reason is that week(today()) returns 8 and in my table it is stored as 08.

So I was thinking I could solve it using

sum({$ <YEAR = {"=year(today())"}, WEEK = {"=If(len(num(week(today())))=1, 0&num(week(today())), num(week(today())))"}>}Sold)

But this gives the same result i.e. the sum for all weeks this year.

Are you not allowed to use If in set analysis?

Is the another way of solving this?

br

Martin

1 Solution

Accepted Solutions
Not applicable
Author

if you need to set week to 2 digits use num(week(today()), '00')

View solution in original post

3 Replies
Not applicable
Author

Week returns an integer, so thats not the problem

Try like this:

sum({$ <YEAR = {"$(=year(today()))"}, WEEK = {"$(=week(today()))"}>}Sold)


Not applicable
Author

I have used this in a load script but it shoudl work in expression as well.  I basically used Right('00' & Week,2) and that then pads out single digits to two and leaves two as were but due to the Right command converts it to text

Not applicable
Author

if you need to set week to 2 digits use num(week(today()), '00')