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
atin
Resolver I
Resolver I

Date Table and how to make it dynamic

Hi All 

 

I have been using this DATE table for some time and been using it for a Sales Table daily refresh.

 

How do I get the end date to be a dynamic one and not have future dates show in the table 

 

I know there is a DateTime.FixedLocalNow() formula that exists and I dont know where to insert this line in my current date table 

 

Many thanks

 

See Date Table details below: 

 

= (StartDate as date, EndDate as date, FYStartMonth as number) as table =>

  let

    DayCount = Duration.Days(Duration.From(EndDate - StartDate)) +1 ,

    Source = List.Dates(StartDate,DayCount,#duration(1,0,0,0)),

    TableFromList = Table.FromList(Source, Splitter.SplitByNothing()),  

    ChangedType = Table.TransformColumnTypes(TableFromList,{{"Column1", type date}}),

    RenamedColumns = Table.RenameColumns(ChangedType,{{"Column1", "Date"}}),

   

in

    AddFY

 

1 ACCEPTED SOLUTION
v-xuding-msft
Community Support
Community Support

Hi @atin ,

 

You could try like this:

= Table.SelectRows(#"Changed Type" , each Date.From([end date]) <= Date.From(DateTime.FixedLocalNow()))
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XZDLDcUwCAR78TkSBn+pxUr/bQS/KNr1u+EdgxjWSioqltXTtcvy1ve1kgGYmAEUgCrUUJG3Y1ID6MekDjC/cucDuYtmgEnL7hjEiUTlIPGRDGeUll+gbKiDCLmHB/f8QDy2I3UY8pDqAAUgvhOoAC4VeTsUlUg/FQvIYMN9X9P/c8WCCuCHXwHgYzUexcfqxyw+Vih+5H4A", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"start date" = _t, #"end date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"start date", type date}, {"end date", type date}}),
    Custom1 = Table.SelectRows(#"Changed Type" , each Date.From([end date]) <= Date.From(DateTime.FixedLocalNow()))
in
    Custom1

 2.PNG1.PNG

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xuding-msft
Community Support
Community Support

Hi @atin ,

 

You could try like this:

= Table.SelectRows(#"Changed Type" , each Date.From([end date]) <= Date.From(DateTime.FixedLocalNow()))
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XZDLDcUwCAR78TkSBn+pxUr/bQS/KNr1u+EdgxjWSioqltXTtcvy1ve1kgGYmAEUgCrUUJG3Y1ID6MekDjC/cucDuYtmgEnL7hjEiUTlIPGRDGeUll+gbKiDCLmHB/f8QDy2I3UY8pDqAAUgvhOoAC4VeTsUlUg/FQvIYMN9X9P/c8WCCuCHXwHgYzUexcfqxyw+Vih+5H4A", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"start date" = _t, #"end date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"start date", type date}, {"end date", type date}}),
    Custom1 = Table.SelectRows(#"Changed Type" , each Date.From([end date]) <= Date.From(DateTime.FixedLocalNow()))
in
    Custom1

 2.PNG1.PNG

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @atin ,

 

use DAX to create the date table.

 

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


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.