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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
amaleranda
Post Patron
Post Patron

Tabla de fechas con un ciclo de 21 días de columna personalizada.

Hola PowerBI Gurus,

Necesito crear una columna en la tabla de datos según los siguientes requisitos.

"El ciclo de informes base, para las métricas de trabajo es de 21 días. Esto se define por el número de la semana calendario

por ejemplo (R1)2020 Semana 1-3[4/Enero/2020 a 24/Enero/2020] ,

(R2)2020Semana 4-6[25/Enero/2020 a 14/Feb/2020],

(R3)2020Semana 7-9[15/Feb/2020 a 6/Mar/2020], etc.

a partir del primer sábado y avanzando hasta el tercer viernes. este R- debe ser incremento a medida que pasa la semana, por ejemplo 2020Semana 10-12 debe ser R4 y por lo tanto cuarto.

este número R debe restablecerse al final de un ciclo de semana de un nuevo año también.

Truco es de 1/enero/2020 a 3/enero/2020 pertenece a un último ciclo de 21 días del año 2019.

Si esto no explica bien puedo enviarle la fecha de muestra tabel.

Si alguien puede ayudarme con esto, realmente agradezco tu ayuda.

saludos

Tu caridad

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

OK, @amaleranda este es realmente bastante trivial, todo lo que necesita s esta columna:

R = ROUNDUP([Sequentialish]/3,0)

Por supuesto, conseguir la columna Sequentialish tomó un poco de TRABAJO!!! Tuve que modificar mi medida rápida secuencial aquí: https://community.powerbi.com/t5/Quick-Measures-Gallery/Sequential/m-p/380231#M116 para tener en cuenta las circunstancias especiales. Ya no es realmente secuencial, pero funciona para este propósito.

De todos modos, esta es la columna:

Sequentialish = 
VAR MaxWeeks = SUMMARIZE(ALL('Table'),'Table'[Year],"MaxWeek",MAX('Table'[WeekNum]))
VAR MyYear = [Year]
VAR MyStart = SUMX(FILTER(MaxWeeks,[Year]<MyYear),[MaxWeek])
VAR firstYear = CALCULATE(FIRSTNONBLANK('Table'[Year],1),ALL('Table'))
VAR __Table = 
    ADDCOLUMNS(
        GROUPBY(
            'Table',
            [Year],
            "__MaxWeek",MAXX(CURRENTGROUP(),[Weeknum])
        ),
        "__Count",COUNTROWS(FILTER(ALL('Table'),'Table'[Year]=EARLIER([Year]) && 'Table'[Weeknum]=[__MaxWeek]))
    )
    VAR __Count = COUNTROWS(FILTER(__Table,[Year]<MyYear && [__Count] < 7))
    VAR __Count2 = COUNTROWS(FILTER('Table',[Year]=MyYear && [Weeknum]=1))
VAR myNum = 
    IF(
        MyYear=firstYear,
        [WeekNum],
        IF([Weeknum]>1 && __Count2 <> 7,
            [Weeknum]-1,
            MyStart+[Weeknum]-__Count
        )
    )
RETURN myNum

He adjuntado un archivo PBIX para usted.



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

OK, @amaleranda este es realmente bastante trivial, todo lo que necesita s esta columna:

R = ROUNDUP([Sequentialish]/3,0)

Por supuesto, conseguir la columna Sequentialish tomó un poco de TRABAJO!!! Tuve que modificar mi medida rápida secuencial aquí: https://community.powerbi.com/t5/Quick-Measures-Gallery/Sequential/m-p/380231#M116 para tener en cuenta las circunstancias especiales. Ya no es realmente secuencial, pero funciona para este propósito.

De todos modos, esta es la columna:

Sequentialish = 
VAR MaxWeeks = SUMMARIZE(ALL('Table'),'Table'[Year],"MaxWeek",MAX('Table'[WeekNum]))
VAR MyYear = [Year]
VAR MyStart = SUMX(FILTER(MaxWeeks,[Year]<MyYear),[MaxWeek])
VAR firstYear = CALCULATE(FIRSTNONBLANK('Table'[Year],1),ALL('Table'))
VAR __Table = 
    ADDCOLUMNS(
        GROUPBY(
            'Table',
            [Year],
            "__MaxWeek",MAXX(CURRENTGROUP(),[Weeknum])
        ),
        "__Count",COUNTROWS(FILTER(ALL('Table'),'Table'[Year]=EARLIER([Year]) && 'Table'[Weeknum]=[__MaxWeek]))
    )
    VAR __Count = COUNTROWS(FILTER(__Table,[Year]<MyYear && [__Count] < 7))
    VAR __Count2 = COUNTROWS(FILTER('Table',[Year]=MyYear && [Weeknum]=1))
VAR myNum = 
    IF(
        MyYear=firstYear,
        [WeekNum],
        IF([Weeknum]>1 && __Count2 <> 7,
            [Weeknum]-1,
            MyStart+[Weeknum]-__Count
        )
    )
RETURN myNum

He adjuntado un archivo PBIX para usted.



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

¿Puede explicar con mejor ejemplo? Si está buscando períodos no estándar, consulte

:

https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@amitchandak ,

Plesae ver la imagen de abajorevisionclmn.PNG

Hola @amaleranda

Compruebe Greg_Deckler pbix, si su respuesta realmente le ayuda, por favor márquelo como una solución para que otros puedan encontrar las respuestas a este tema rápidamente.

Si no, por favor no dude en hacestarme lo saber.

Saludos

Maggie

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors
Top Kudoed Authors