Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

7 días para cada semana, a partir de la primera semana entera del año

Hola

Tengo un campo de fecha, y necesito extraer la semana para cada fecha.

Sé que puedo usar WEEKNUM, pero la salida de esta función es semana que no tiene 7 días..

Así que necesito tener todas las semanas con 7 días, a partir de la primera semana que está completa en un año.

¿Cómo puedo hacer esto?

Weeks.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Gracias.

Casi funciona. Pero fue útil editar mi código.

Esto es para lo que necesito:

-Inicio de la semana el lunes

-7 Días por cada semana

Year&WeekNo With MondayAsFirstDay = 
IF (
--If (Week=1) AND (Year of MondayOfWeek )<> (Year of the DateField), Then
    WEEKNUM ( Calendar[Date];2 ) = 1 && YEAR(CalendarioIN[DateMondayofWeek])<>Year(Calendar[Date]); 
    YEAR ( Calendar[Date] ) - 1 & "/" & Weeknum(CalendarioIN[DateMondayofWeek])-1;
        IF(
            --If (Week=53) AND (Year of SundayOfWeek )<> (Year of the DateField), Then
            WEEKNUM(Calendar[Date])=53 && YEAR(CalendarioIN[DateSundayofWeek])<>Year(Calendar[Date]);
            YEAR(Calendar[Date]) &"/" & WeekNum(Calendar[Date])-1;
            YEAR ( Calendar[Date] ) & "/" & WEEKNUM ( Calendar[Date];2 ) - 1
        )
    )


--Also I've created two calculated columns
DateMondayofWeek = CalendarioIN[Fecha]-Weekday(CalendarioIN[Fecha];3)

DateSundayofWeek = CalendarioIN[Fecha]-Weekday(CalendarioIN[Fecha];3) + 7

Creo que esta debería ser una función incorporada en PowerBi, como lo es en Qlikview

View solution in original post

4 REPLIES 4
v-gizhi-msft
Community Support
Community Support

Hola

Por favor, pruebe estas columnas:

WeekDayNo = WEEKDAY('Table'[Date])
Day = DAY('Table'[Date])
Year&WeekNo =
IF (
    WEEKNUM ( 'Table'[Date] ) = 1,
    "Week" & " "
        & YEAR ( 'Table'[Date] ) - 1 & "/" & 52,
    IF (
        WEEKNUM ( 'Table'[Date] ) - 1 < 10,
        "Week" & " "
            & YEAR ( 'Table'[Date] ) & "/0"
            & WEEKNUM ( 'Table'[Date] ) - 1,
        "Week" & " "
            & YEAR ( 'Table'[Date] ) & "/"
            & WEEKNUM ( 'Table'[Date] ) - 1
    )
)

A continuación, elija matrix visual, el resultado muestra:

1.PNG

Aquí está mi archivo pbix de prueba:

pbix

Espero que esto ayude.

Saludos,

Giotto

Anonymous
Not applicable

Gracias.

Casi funciona. Pero fue útil editar mi código.

Esto es para lo que necesito:

-Inicio de la semana el lunes

-7 Días por cada semana

Year&WeekNo With MondayAsFirstDay = 
IF (
--If (Week=1) AND (Year of MondayOfWeek )<> (Year of the DateField), Then
    WEEKNUM ( Calendar[Date];2 ) = 1 && YEAR(CalendarioIN[DateMondayofWeek])<>Year(Calendar[Date]); 
    YEAR ( Calendar[Date] ) - 1 & "/" & Weeknum(CalendarioIN[DateMondayofWeek])-1;
        IF(
            --If (Week=53) AND (Year of SundayOfWeek )<> (Year of the DateField), Then
            WEEKNUM(Calendar[Date])=53 && YEAR(CalendarioIN[DateSundayofWeek])<>Year(Calendar[Date]);
            YEAR(Calendar[Date]) &"/" & WeekNum(Calendar[Date])-1;
            YEAR ( Calendar[Date] ) & "/" & WEEKNUM ( Calendar[Date];2 ) - 1
        )
    )


--Also I've created two calculated columns
DateMondayofWeek = CalendarioIN[Fecha]-Weekday(CalendarioIN[Fecha];3)

DateSundayofWeek = CalendarioIN[Fecha]-Weekday(CalendarioIN[Fecha];3) + 7

Creo que esta debería ser una función incorporada en PowerBi, como lo es en Qlikview

Greg_Deckler
Super User
Super User

Hice algo por esto aquí: https://community.powerbi.com/t5/Quick-Measures-Gallery/Week-Ending/m-p/389293#M120

O en Secuencial, mire a través de los comentarios. Ya he resuelto esto antes. https://community.powerbi.com/t5/Quick-Measures-Gallery/Sequential/m-p/380231#M116

Echa un vistazo al archivo adjunto.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Gracias.

Pero no puedo encontrarlo en el post o archivos adjuntos 😕

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors