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

Dates Clarification

Good Afternoon, 

 

I have a date column and I want to change values in another column based on when the new financial year starts.

 

I just want to clarify would the below method be the correct Syntax/approach for this to say if the date is greater than 31st March I.E 1st April it would trigger it from 1st April 2023?

 

each [Year],
each if [Max Update Date]>31/03/2023 then "2023/24 Delivered to Date" else [Year],
Replacer.ReplaceText,{"Year"})

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @pigsinblankets 

here are some information for your reference

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQHQktLM6VYHRDHCMExgsiY4+RYgDnGcE4sAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [date = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source,"1996","2005",Replacer.ReplaceText,{"date"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Replaced Value",{{"date", type date}})
in
    #"Changed Type"

Solved: Change years in a Date column in Query Editor - Microsoft Power BI Community

 

=if [Release date] < #date(2020, 1, 1) then  1
      else if [Release date] > #date(2019, 12, 31) and [Release date] < #date(2021, 1, 1) then 2
      else if [closed date] < #date(2021, 1, 1) then 3
      else  0

Solved: Power query - if function with dates - Microsoft Power BI Community

 

 

 

Best Regards,

Community Support Team _Tang

If this post helps, 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-xiaotang
Community Support
Community Support

Hi @pigsinblankets 

here are some information for your reference

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQHQktLM6VYHRDHCMExgsiY4+RYgDnGcE4sAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [date = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source,"1996","2005",Replacer.ReplaceText,{"date"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Replaced Value",{{"date", type date}})
in
    #"Changed Type"

Solved: Change years in a Date column in Query Editor - Microsoft Power BI Community

 

=if [Release date] < #date(2020, 1, 1) then  1
      else if [Release date] > #date(2019, 12, 31) and [Release date] < #date(2021, 1, 1) then 2
      else if [closed date] < #date(2021, 1, 1) then 3
      else  0

Solved: Power query - if function with dates - Microsoft Power BI Community

 

 

 

Best Regards,

Community Support Team _Tang

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

Thanks so much I have this working now was struggling to find the appropriate historical forum thread! 🙂 

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.