Weeknum Function Is Not Working Correctly

I got an issue using DAX function. The thing is that I'm using a dataset and I need to caclulate the date using weeks but unfortunately I can't find it directly. So, I have created a new measure and I tried to apply the function below : Week Number = WEEKNUM(Table1[Date],2)

And this give me the following error : "A single value for column 'Date' in table 'Table1' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."

The structure of my file is like this:

DATE        N° PAGE 
26/06/2018  E2  17
27/06/2018  E6  59  
28/06/2018  E7  179 
29/06/2018  E8  223
30/06/2018  E11 205 
01/07/2018  F13 202

What am I missing ?

Thanks in advance.

0

1 Answer

I don't think this is a problem having to do with the WEEKNUM function, but has to do with the difference between a measure and a calculated column.

If you are creating a calculated column then your formula should work because DAX uses the row context to know which single date to use in the calculation.

If you are creating a measure then it is not associated with any single row, so you need to specify an aggregate so it has a single date value to work with.


Reference: Calculated columns and measures in DAX

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest