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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Pillic
Helper II
Helper II

Calendar Days Decades

Hello Community,

 

I am looking for an option to have dynamicaly (based on date table) calculated the day decades.

Each month has 3 decades with start day 1st, 11th and 21st, so the result would be a new column "Decade" with values 1,2,3 for each month.

 

Pillic_0-1613118212718.png

 

After:

 

Pillic_0-1613118755820.png

 

 

In the visuals I want to add this filter to show results for 1st, 2nd and/or 3rd decade.

 

It would be great if some one would have an idea how to add this to the M Code.

 

Thanks & Kind Regards

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello @Pillic 

 

you can add a nestef if-function to achieve this. Here the formula

if [Tag]<11 then 1 else if [Tag]<21 then 2 else 3

If you would not have the day-value in your table, but only a date-value you could substitute the [Tag] with Date.Day([Date]).

here a complete example

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Lc67DcAwDAPRXVSnCKk4n1kM779GAJ6bU8UHzVmqdcxy2umVjvROn/RNv1Qnh7WYi70AhCAIYQhEKEbx/gHFKEYxilGMYhSjNErvX2qtHw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Tag = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Tag", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Decade", each if [Tag]<11 then 1 else if [Tag]<21 then 2 else 3)
in
    #"Added Custom"

 

Jimmy801_0-1613119671521.png

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

 

View solution in original post

2 REPLIES 2
Jimmy801
Community Champion
Community Champion

Hello @Pillic 

 

you can add a nestef if-function to achieve this. Here the formula

if [Tag]<11 then 1 else if [Tag]<21 then 2 else 3

If you would not have the day-value in your table, but only a date-value you could substitute the [Tag] with Date.Day([Date]).

here a complete example

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Lc67DcAwDAPRXVSnCKk4n1kM779GAJ6bU8UHzVmqdcxy2umVjvROn/RNv1Qnh7WYi70AhCAIYQhEKEbx/gHFKEYxilGMYhSjNErvX2qtHw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Tag = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Tag", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Decade", each if [Tag]<11 then 1 else if [Tag]<21 then 2 else 3)
in
    #"Added Custom"

 

Jimmy801_0-1613119671521.png

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

 

Great that works, Thanks a lot!

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors