Forum Discussion

giovissimo's avatar
giovissimo
Helper I
3 years ago
Solved

Passing two values to Weeknum function

Good morning everybody,

 

I hope you can help me solve the following problem:

the source table feeding my PBI report is extracted on Monday evenings from a system, and I have to calculate the new orders issued by the purchasing department in the last week. To do that, I thought of filtering the week number through the WEEKNUM function, but the WEEKNUM function starts counting from Mondays, so the instruction:

WEEKNUM(MAX([OrderDate]))

would only yield the orders issued on a single day, i.e. the Monday of the data extraction. Therefore, the agreed solution is to count the previous week orders too (8 days, but there comes the problem: how shoud I convince Dax 🙂 to pass two values to the WEEKNUM function, i.e. the last week plus the preious one ? I wrote the following filter:

 

WEEKNUM ( Orders[OrderDate] ) = OR ( WEEKNUM ( MAX ( Orders[OrderDate] ) ), WEEKNUM ( MAX ( Orders[OrderDate] ) )-1)

 

but obviously I get a message saying that Dax doesn’t support comparison between Integer values and True/False values.

What I want to obtain from my Count(OrderID), given that were 27 orders issued in week 49 and 31 orders in week 48, is 27+31 =58. Is it possible ?

I hope all the above sounds clear.

 

Giovanni

2 Replies