Hi, experts, any help? I have this code:
ifs(
Weeknum([Date])=1, “Week 1",
Weeknum([Date])=2, "Week 2”,
.
.
.
Weeknum([Date])=52, "Week 52”
)
That code works fine, but I dont want to write 52 lines
This is an idea but something like this is possbile?
for i in (1, 52) {
if(
Weeknum([Date])= i, "Week "+ i
)
}
Thanks!
Since the number in your string "Week X" is the same as the result of WEEKNUM([Date]), you can directly construct the string using concatenation.
"Week " & WEEKNUM([Date])
So, if WEEKNUM([Date]) is 3, the result will be "Week 3".
The WEEKNUM() function returns 0 if the date is not recognized. If this happens, the formula above would result in "Week 0". If you want to display something else (like a blank string or "N/A") in such cases, you can wrap the formula in an IF() statement:
IF(
WEEKNUM([Date]) > 0,
"Week " & WEEKNUM([Date]),
"" /* Or "N/A", or "Invalid Date" */
)
User | Count |
---|---|
18 | |
11 | |
7 | |
5 | |
5 |