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
Geraldine
Frequent Visitor

Convert Months to weeks

 

Hello Guys., Hope you can suggest something

 

I have a column with "X" numbers of rows with amounts and linked to another column with dates, but just by Month , (I can add year-Q-month and day ) but I need to split the information by WEEK, and I just have this format for date -  01/01/2016 -02/01/2016 - 03/01/2016 - 04/01/2016 etc etc , how would you split those (let s say 500 rows) with date 01/01/2016 by weeks ? any ideas ? I need for those rows equally distributed a week column with this :

 

1/31/2016
1/24/2016
1/17/2016
1/10/2016
1/3/2016

 

Your help will eb highly appreciated !    😄

1 ACCEPTED SOLUTION
Geraldine
Frequent Visitor

Hello everyone, I found a very simple solution ! I just split the total I had in colum (YTD) btw 52 weeks , and that result multiplied per the week we are currently ( week 25). Thank you all for your help !  😄

6-20-2016 5-28-25 PM.png

View solution in original post

10 REPLIES 10
Geraldine
Frequent Visitor

Hello everyone, I found a very simple solution ! I just split the total I had in colum (YTD) btw 52 weeks , and that result multiplied per the week we are currently ( week 25). Thank you all for your help !  😄

6-20-2016 5-28-25 PM.png

kcantor
Community Champion
Community Champion

@Geraldine

 Re-do

I have actually dealt with this before. I simply split the column in PowerQuery to only show the end date (last part of the range). I used a date table that I keep as a date dim with week numbers assigned. I related the dates and then put the week number on my axis.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




KHorseman
Community Champion
Community Champion

For this sort of thing it's usually best to have your fact table with a date column linked to a separate date table. That date table would have a continuous series of dates covering the full range you need, plus other columns with category info related to those dates (week, month, year, quarter). My preferred method for week is to use the last date of the week from the date in question. In your query you can write a custom column using the Date.EndOfWeek function.

 

Here's one version of the query I use to create date tables. There are lots of other examples around as well.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks a lot, ! Thats power query right ?

@Geraldine my example and the Date.EndOfWeek function are Power Query, yes.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




To @KHorseman's point, if you had a Date table like DateStream in the Azure Data Marketplace, you could relate your fact table to your date table on the actual date in the fact table (if it is there) and your date table should be able to tell you what week of the year that date falls on.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Yeah, that's pretty much what I'm trying to describe. You would never expose your actual date column in any visual on the report; you'd only put the Week column from the date table down, and the relationship between your table's date column and the date table's primary date column would do all the work for you.

 

I keep meaning to check out that DateStream table. My date table is an ok example, but it sure does load slowly. Too many calculated columns in the query I'm sure.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@KHorseman here is the direct link to it:

http://datamarket.azure.com/dataset/boyanpenev/datestream

 

Free and you only need to download it once per data model.


@ 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!:
The Definitive Guide to Power Query (M)

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

I'm not clear on your data format (original) but I am betting that WEEKNUM will play a role in this:

 

https://msdn.microsoft.com/en-us/library/ee634572.aspx


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank you, !  That could be a solution if I use DAX , but in this case I am using power query ... 😞

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.