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
Oomsen
Helper III
Helper III

Monthly value by week

I would like to show a monthly value by week.

Month      Week     Value

January     1            337.500

                  2

                  3

                  4 

                  5

February    6           335.000

                  7

 

Currently the value is only shown by month. I would like to see 337.500 in week 2, 3, 4 and 5.

The data is add from a custom excelsheet.  

 

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @Oomsen 

Please see the below M code, this will expand your months to weeks.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUByIjA0MLJR2lQwsUYMjYzNzUwODQAqCoMUJJrA5EhxFWHUANEB1GFnAlMB3GWHUYIdsBVRIbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t, Value = _t, #"End date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Value", Int64.Type}, {"End date", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Distinct( List.Transform( List.Dates( [Date],  Duration.Days( [End date] - [Date] ), #duration( 1, 0, 0, 0 ) ), each Date.WeekOfYear(_) ) )),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Custom",{{"Custom", type number}})
in
    #"Changed Type1"
 
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

View solution in original post

9 REPLIES 9
Mariusz
Community Champion
Community Champion

Hi @Oomsen 

 

Please see the below creenshot

 

image.png

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

@Mariusz 

This isn't the solution unfortunately. 

Mariusz
Community Champion
Community Champion

Hi @Oomsen 

Is there a reason why?

 

Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski

 

@Mariusz  i don't know. But the result in my report doesn't change. 

Maybe another way is to say that from 1-1-19 to 1-2-19 the value is xxx and from 1-2-19 to 1-3-19 it's xxy?

Mariusz
Community Champion
Community Champion

Hi @Oomsen 

 

Is this the result you aiming for? then the instructions I gave you earlier should result in this.

image.png

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

@Mariusz  

My current data is like this:

 

Date              Value        End date

1-1-2018       367500      31-1-2018

1-2-2018       365000      28-2-2018

1-3-2018       362500      31-3-2018

 

So where do i need to filldown?

 

Mariusz
Community Champion
Community Champion

Hi @Oomsen 

Please see the below M code, this will expand your months to weeks.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUByIjA0MLJR2lQwsUYMjYzNzUwODQAqCoMUJJrA5EhxFWHUANEB1GFnAlMB3GWHUYIdsBVRIbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t, Value = _t, #"End date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Value", Int64.Type}, {"End date", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Distinct( List.Transform( List.Dates( [Date],  Duration.Days( [End date] - [Date] ), #duration( 1, 0, 0, 0 ) ), each Date.WeekOfYear(_) ) )),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Custom",{{"Custom", type number}})
in
    #"Changed Type1"
 
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

v-chuncz-msft
Community Support
Community Support

@Oomsen 

 

You may use Table.FillDown in Query Editor.

= Table.FillDown(#"Changed Type",{"Value"})
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-chuncz-msft 

Thanks for your reaction. 

Can you be a little more specific where i need to add this in the query editor. 

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.