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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
JUAN_1969
Helper I
Helper I

Extraer semana iso de un campo fecha.

Muy buenas.

Estoy intentando crear una columna con la semana iso en el editor de power query en powor bi.

He encontrado esta formula, la cual pego en una columna personalizada, pero al ejecutarla me da error en los datos.

La fórmula de Ron de Bruin, trasladada al lenguaje M de Power Query queda como sigue:

Number.RoundDown((Int64.From([Fecha])- Int64.From(#date(Date.Year(Date.From(Int64.From([Fecha])-(if (Date.DayOfWeek(Date.AddDays([Fecha],1)))=0 then 7 else (Date.DayOfWeek(Date.AddDays([Fecha],1))))+4)),1,3))+
(if (Date.DayOfWeek(Date.AddDays((#date(Date.Year(Date.From(Int64.From([Fecha])-(if (Date.DayOfWeek(Date.AddDays([Fecha],1)))=0 then 7 else (Date.DayOfWeek(Date.AddDays([Fecha],2))))+4)),1,3)),1)))=0
then 7 else (Date.DayOfWeek(Date.AddDays((#date(Date.Year(Date.From(Int64.From([Fecha])-(if (Date.DayOfWeek(Date.AddDays([Fecha],1)))=0 then 7 else (Date.DayOfWeek(Date.AddDays([Fecha],1))))+4)),1,3)),2))))+5)/7)

Alguna ayuda, Gracias

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @JUAN_1969 

 

To get ISO week from a date with M codes, you can refer to this page on GitHub: M functions to convert between ISO 8601 Week & Year ⇄ dates

 

Also, I have an example in this thread which shows how to use this custom function.

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

View solution in original post

3 REPLIES 3
Anabela
Frequent Visitor

 Gracias es muy colaboración

v-jingzhang
Community Support
Community Support

Hi @JUAN_1969 

 

Have you solved this problem? If so, you may accept the appropriate post as the solution or post your own solution to help other members find it quickly. Thanks.

 

Regards,
Community Support Team _ Jing

v-jingzhang
Community Support
Community Support

Hi @JUAN_1969 

 

To get ISO week from a date with M codes, you can refer to this page on GitHub: M functions to convert between ISO 8601 Week & Year ⇄ dates

 

Also, I have an example in this thread which shows how to use this custom function.

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Solution Authors
Top Kudoed Authors