Forum Discussion

kasife's avatar
kasife
Helper V
2 years ago
Solved

Week per month

Hi guys.

 

I'm trying to create a calculated column that gives me the week of the month according to the calendar of the year. As shown in the image below, we can see that the 1st week of August starts on the 1st and ends on the 6th.

I am using the following measure, but it is not working

SemanaDoMes = 
VAR DataAtual = [Date]
VAR PrimeiroDiaDoMes = DATE(YEAR(DataAtual), MONTH(DataAtual), 1)
VAR DiaDaData = DAY(DataAtual)
VAR DiaDaSemana = WEEKDAY(PrimeiroDiaDoMes)
VAR DiasNoPrimeiraSemana = 7 - DiaDaSemana + 1
VAR Semana = INT((DiaDaData - DiasNoPrimeiraSemana) / 7) + 1
RETURN
 IF(DiaDaData <= DiasNoPrimeiraSemana, "1ª Semana", Semana & "ª Semana")

This is the result it is returning to me

How could I adjust this measurement?