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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It 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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors
Top Kudoed Authors