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

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.

Reply
cecitorresHF
Helper I
Helper I

Semanas continuas

Hola 

Me gustaria saber si alguien sabe como generar una columna con semanas seguidas 1,2,3 etc, pero no empiece en semana 1 cada vez que el a'o cambia, por ejemplo en este caso en donde del 26/12/22 al 1/1/23 seria la semana completa (53) pero como cambia de a;o el ultimo dia de la semana me cambia a semana 1 de nuevo, hay alguna manera que tome el 1/1/23 como semana 53 y continue como semana 54 etc.?

cecitorresHF_1-1693532989607.png

 

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @cecitorresHF ,

 

Here are the steps you can follow:

1. Create calculated column.

week =
WEEKNUM('Table'[Date],2)
Column =
RANKX(
    'Table','Table'[Date],,ASC)
Year =
YEAR('Table'[Date])
True =
var _table1=
FILTER(
    'Table',    'Table'[Date]=MINX(FILTER(ALL('Table'),'Table'[week]=EARLIER('Table'[week])&&'Table'[Year]=EARLIER('Table'[Year])),[Date]))
var _table2=
ADDCOLUMNS(
    _table1,"rank",
RANKX(_table1,[Date],,ASC))
return
IF(
    'Table'[Date]=
    MINX(
        FILTER(ALL('Table'),
        'Table'[Year]=EARLIER('Table'[Year])&&'Table'[week]=EARLIER('Table'[week])),[Date]),
        MINX(
            FILTER(
               _table2,[Date]=EARLIER('Table'[Date])),[rank])
        ,0)
Week_Number =
MAXX(
    FILTER(ALL('Table'),
    'Table'[Year]=EARLIER('Table'[Year])&&'Table'[week]=EARLIER('Table'[week])),[True])

2. Result:

vyangliumsft_0-1693833969547.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @cecitorresHF ,

 

Here are the steps you can follow:

1. Create calculated column.

week =
WEEKNUM('Table'[Date],2)
Column =
RANKX(
    'Table','Table'[Date],,ASC)
Year =
YEAR('Table'[Date])
True =
var _table1=
FILTER(
    'Table',    'Table'[Date]=MINX(FILTER(ALL('Table'),'Table'[week]=EARLIER('Table'[week])&&'Table'[Year]=EARLIER('Table'[Year])),[Date]))
var _table2=
ADDCOLUMNS(
    _table1,"rank",
RANKX(_table1,[Date],,ASC))
return
IF(
    'Table'[Date]=
    MINX(
        FILTER(ALL('Table'),
        'Table'[Year]=EARLIER('Table'[Year])&&'Table'[week]=EARLIER('Table'[week])),[Date]),
        MINX(
            FILTER(
               _table2,[Date]=EARLIER('Table'[Date])),[rank])
        ,0)
Week_Number =
MAXX(
    FILTER(ALL('Table'),
    'Table'[Year]=EARLIER('Table'[Year])&&'Table'[week]=EARLIER('Table'[week])),[True])

2. Result:

vyangliumsft_0-1693833969547.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

lbendlin
Super User
Super User

Don't waste your time. Use an external table (for example an Excel sheet in a sharepoint)  that has everything precomputed a couple years in advance.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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