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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Convert from DAX to M

Hi, I have a dynamic calendar table created in DAX and wonder if this is possible to have in M?

 

Period Check =
var this_year = YEAR(TODAY())
var this_month = MONTH(TODAY())
var this_day = DAY(TODAY())
return
{
DATE(this_year, this_month, this_day-2),
DATE(this_year, this_month, this_day-9),
DATE(this_year, this_month, this_day-16),
DATE(this_year, this_month, this_day-23)
}
1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello@Anonymous 

 

there are for sure multiple ways to create this table. Here one simple approach

let
    Today = Date.From(DateTime.FixedLocalNow()),
    CreateCalendareList = {Date.AddDays(Today, -2), Date.AddDays(Today, -9), Date.AddDays(Today, -16), Date.AddDays(Today, -23)},
    ConvertListToTable = Table.FromList(CreateCalendareList, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    ChangeType = Table.TransformColumnTypes(ConvertListToTable,{{"Column1", type date}}),
    RenameColumn = Table.RenameColumns(ChangeType,{{"Column1", "Date"}})
in
    RenameColumn

 

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

1 REPLY 1
Jimmy801
Community Champion
Community Champion

Hello@Anonymous 

 

there are for sure multiple ways to create this table. Here one simple approach

let
    Today = Date.From(DateTime.FixedLocalNow()),
    CreateCalendareList = {Date.AddDays(Today, -2), Date.AddDays(Today, -9), Date.AddDays(Today, -16), Date.AddDays(Today, -23)},
    ConvertListToTable = Table.FromList(CreateCalendareList, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    ChangeType = Table.TransformColumnTypes(ConvertListToTable,{{"Column1", type date}}),
    RenameColumn = Table.RenameColumns(ChangeType,{{"Column1", "Date"}})
in
    RenameColumn

 

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.