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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
SammiF1244
Helper I
Helper I

Replace date if less than....

I can't figure out what I am doing wrong even looking at examples.

I've tried this:

= Table.ReplaceValue(each #"Removed Columns1",each if <#date(2015, 10, 1),then #date(2015, 10, 1), else [CODE_EFFECTIVE_DATE],Replacer.ReplaceValue,{"CODE_EFFECTIVE_DATE"})

and this: 

= Table.ReplaceValue(#"CODE_EFFECTIVE_DATE",each if <#date(2015, 10, 1),then #date(2015, 10, 1), else [CODE_EFFECTIVE_DATE],Replacer.ReplaceValue,{"CODE_EFFECTIVE_DATE"})

and this:

= Table.ReplaceValue(#"CODE_EFFECTIVE_DATE",< #date(2015, 10, 1),#date(2015, 10, 1),Replacer.ReplaceValue,{"CODE_EFFECTIVE_DATE"})

2 ACCEPTED SOLUTIONS
ronrsnfld
Super User
Super User

Here's one way:

 

 

 

    #"Changed Type" = Table.TransformColumnTypes(Source,{{"CODE_EFFECTIVE_DATE", type date}}),
    #"Replace Date" = Table.ReplaceValue(
        #"Changed Type",
        each [CODE_EFFECTIVE_DATE],
        #date(2015,10,1),
        (x,y,z) => if x < z then z else y,
        {"CODE_EFFECTIVE_DATE"}
    ),
    #"Changed Type1" = Table.TransformColumnTypes(#"Replace Date",{{"CODE_EFFECTIVE_DATE", type date}})
in
    #"Changed Type1"

 

 

and here is another with slightly longer code:

 

   #"Changed Type" = Table.TransformColumnTypes(Source,{{"CODE_EFFECTIVE_DATE", type date}}),
    #"Replace Date" = Table.ReplaceValue(
        #"Changed Type",
        each [CODE_EFFECTIVE_DATE],
        each if [CODE_EFFECTIVE_DATE] < #date(2015,10,1) then #date(2015,10,1) else [CODE_EFFECTIVE_DATE],
        Replacer.ReplaceValue,
        {"CODE_EFFECTIVE_DATE"}
    ),
    #"Changed Type1" = Table.TransformColumnTypes(#"Replace Date",{{"CODE_EFFECTIVE_DATE", type date}})
in
    #"Changed Type1"

 

 

ronrsnfld_0-1698887920464.png

 

 

View solution in original post

SammiF1244
Helper I
Helper I

Thank you. I didn't understand the first one, so I used the second, but I am getting change type already defined, so I left out the first line 

#"Changed Type" = Table.TransformColumnTypes(Source,{{"CODE_EFFECTIVE_DATE", type date}}),

and it worked 🙂

 

#"Replace Date" = Table.ReplaceValue(
#"Changed Type",
each [CODE_EFFECTIVE_DATE],
each if [CODE_EFFECTIVE_DATE] < #date(2015,10,1) then #date(2015,10,1) else [CODE_EFFECTIVE_DATE],
Replacer.ReplaceValue,
{"CODE_EFFECTIVE_DATE"}
),
#"Changed Type1" = Table.TransformColumnTypes(#"Replace Date",{{"CODE_EFFECTIVE_DATE", type date}})
in
#"Changed Type1"

View solution in original post

2 REPLIES 2
SammiF1244
Helper I
Helper I

Thank you. I didn't understand the first one, so I used the second, but I am getting change type already defined, so I left out the first line 

#"Changed Type" = Table.TransformColumnTypes(Source,{{"CODE_EFFECTIVE_DATE", type date}}),

and it worked 🙂

 

#"Replace Date" = Table.ReplaceValue(
#"Changed Type",
each [CODE_EFFECTIVE_DATE],
each if [CODE_EFFECTIVE_DATE] < #date(2015,10,1) then #date(2015,10,1) else [CODE_EFFECTIVE_DATE],
Replacer.ReplaceValue,
{"CODE_EFFECTIVE_DATE"}
),
#"Changed Type1" = Table.TransformColumnTypes(#"Replace Date",{{"CODE_EFFECTIVE_DATE", type date}})
in
#"Changed Type1"

ronrsnfld
Super User
Super User

Here's one way:

 

 

 

    #"Changed Type" = Table.TransformColumnTypes(Source,{{"CODE_EFFECTIVE_DATE", type date}}),
    #"Replace Date" = Table.ReplaceValue(
        #"Changed Type",
        each [CODE_EFFECTIVE_DATE],
        #date(2015,10,1),
        (x,y,z) => if x < z then z else y,
        {"CODE_EFFECTIVE_DATE"}
    ),
    #"Changed Type1" = Table.TransformColumnTypes(#"Replace Date",{{"CODE_EFFECTIVE_DATE", type date}})
in
    #"Changed Type1"

 

 

and here is another with slightly longer code:

 

   #"Changed Type" = Table.TransformColumnTypes(Source,{{"CODE_EFFECTIVE_DATE", type date}}),
    #"Replace Date" = Table.ReplaceValue(
        #"Changed Type",
        each [CODE_EFFECTIVE_DATE],
        each if [CODE_EFFECTIVE_DATE] < #date(2015,10,1) then #date(2015,10,1) else [CODE_EFFECTIVE_DATE],
        Replacer.ReplaceValue,
        {"CODE_EFFECTIVE_DATE"}
    ),
    #"Changed Type1" = Table.TransformColumnTypes(#"Replace Date",{{"CODE_EFFECTIVE_DATE", type date}})
in
    #"Changed Type1"

 

 

ronrsnfld_0-1698887920464.png

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors