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
primolee
Helper V
Helper V

Altering data into different table layout

Hello everyone,

 

Currently I have this data source:

weekTier.jpg

 

I want to alter it into the following:

weekTier2.jpg

 

Is there a way to achieve this in Power Query?  If not, is it possible in BI using DAX?

 

Thank you.

1 ACCEPTED SOLUTION
ImkeF
Super User
Super User

Hi @primolee  

please check out the function that I've written for it here: https://www.thebiccountant.com/2017/12/11/date-datesbetween-retrieve-dates-between-2-dates-power-bi-... 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

3 REPLIES 3
v-lid-msft
Community Support
Community Support

Hi @primolee ,

 

We can create a custom column in power query editor and expand it to rows to meet your requiremnet:

 

List.Dates([WeekStart],Duration.Days([WeekEnd]-[WeekStart])+1,#duration(1,0,0,0))

 

3.jpg4.jpg5.jpg

 

All the queries are here:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwtNQ31TdU0oExTYHMEDOlWB24pBlC0tAIJGuqFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [WeekStart = _t, WeekEnd = _t, #"week name" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"WeekStart", type date}, {"WeekEnd", type date}, {"week name", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Date", each List.Dates([WeekStart],Duration.Days([WeekEnd]-[WeekStart])+1,#duration(1,0,0,0))),
    #"Expanded Date" = Table.ExpandListColumn(#"Added Custom", "Date")
in
    #"Expanded Date"


Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ImkeF
Super User
Super User

Hi @primolee  

please check out the function that I've written for it here: https://www.thebiccountant.com/2017/12/11/date-datesbetween-retrieve-dates-between-2-dates-power-bi-... 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Hello both,

 

Thank you so much, both of you!

 

Both are the solutions to my question, it is super difficult for me to decide whose answer to accept.

 

Dong's solution is very simple, whereas ImkeF's solution gives more flexibility of display by different interval.

 

I will accept ImkeF's reply as solution, but again, both work perfectly.

 

Thank you both for taking the time to help, greatly appreciated!

 

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.

Top Solution Authors
Top Kudoed Authors