Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I want to calculate week number of the month ( week 1, week 2, week 3, week 4 & week 5 ).
I tried using the formula
Solved! Go to Solution.
Hi @vrushabjain510 ,
Create 3 columns as below:
Sunday = IF(WEEKDAY('Table'[Date],1)=1,1,BLANK())
rank =
var _rank=RANKX(FILTER(ALL('Table'),MONTH('Table'[Date])=MONTH(EARLIER('Table'[Date]))&&'Table'[Sunday]<>BLANK()),'Table'[Date],,ASC,Dense)
return
IF('Table'[Sunday]<>BLANK(),_rank,BLANK())
weeknum =
var _maxdate=CALCULATE(MAX('Table'[Date]),FILTER('Table','Table'[Date]<EARLIER('Table'[Date])&&'Table'[Sunday]=1))
Return
IF('Table'[Sunday]=1,"week"&'Table'[rank],
IF(_maxdate=BLANK(),BLANK(),
"week"&CALCULATE(MAX('Table'[rank]),FILTER(ALL('Table'),'Table'[Date]=_maxdate))))
And you will see:
For the related .pbix file,pls see attached.
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
Hi @vrushabjain510 ,
Create 3 columns as below:
Sunday = IF(WEEKDAY('Table'[Date],1)=1,1,BLANK())
rank =
var _rank=RANKX(FILTER(ALL('Table'),MONTH('Table'[Date])=MONTH(EARLIER('Table'[Date]))&&'Table'[Sunday]<>BLANK()),'Table'[Date],,ASC,Dense)
return
IF('Table'[Sunday]<>BLANK(),_rank,BLANK())
weeknum =
var _maxdate=CALCULATE(MAX('Table'[Date]),FILTER('Table','Table'[Date]<EARLIER('Table'[Date])&&'Table'[Sunday]=1))
Return
IF('Table'[Sunday]=1,"week"&'Table'[rank],
IF(_maxdate=BLANK(),BLANK(),
"week"&CALCULATE(MAX('Table'[rank]),FILTER(ALL('Table'),'Table'[Date]=_maxdate))))
And you will see:
For the related .pbix file,pls see attached.
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
Hi @vrushabjain510 ,
We can get the weekno using a WEEKNUM() function. Ex. given below
WEEKNUM(Table_Name[Date],1)
@vrushabjain510 , Create columns like
month week No = quotient(datediff([eomonth([date],-1)+1,[date],day),7)+1
Week name = if([month week No] < 4, "Week " & [month week No] , "Week 4 & Week 5")
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
105 | |
78 | |
67 | |
63 |
User | Count |
---|---|
148 | |
107 | |
106 | |
83 | |
70 |