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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply

changing the value of a column with condition on power query

Hi

I succeeded to add a column with a change of date value on a condition =>

= Table.AddColumn(#"Lignes filtrées3", "New Column", each if [fAllDayEvent] = "NON" then [DATE DEBUT] + #duration(0,-7,0,0) else [DATE DEBUT])

I would like to do the same but on the column itself [DATE DEBUT].

How can I do that?

Thanks for your help.

1 ACCEPTED SOLUTION

This way should be clearer because we talk about power query =>

#"Query" = Table.ReplaceValue(#"PreviousQuery", each [DATE FIN], each if [fAllDayEvent] = false then [DATE FIN] + #duration(0,-7,0,0) else [DATE FIN], Replacer.ReplaceValue, {"DATE FIN"})

View solution in original post

11 REPLIES 11

This way should be clearer because we talk about power query =>

#"Query" = Table.ReplaceValue(#"PreviousQuery", each [DATE FIN], each if [fAllDayEvent] = false then [DATE FIN] + #duration(0,-7,0,0) else [DATE FIN], Replacer.ReplaceValue, {"DATE FIN"})

Hello

I found by myself, here is the solution =>

#"Request" = Table.ReplaceValue(#"PreviousRequest", each [DATE FIN], each if [fAllDayEvent] = false then [DATE FIN] + #duration(0,-7,0,0) else [DATE FIN], Replacer.ReplaceValue, {"DATE FIN"})

I found by myself here is the solution =>

= Table.ReplaceValue(#"test", each [DATE DEBUT], each if [fAllDayEvent] = false then [DATE DEBUT] + #duration(0,-7,0,0) else [DATE DEBUT], Replacer.ReplaceValue, {"DATE DEBUT"})

 I tried this

 

NextTableReq= Table.ReplaceValue(#"PreviousTableReq", each if [fAllDayEvent] = "TRUE" then [DATE DEBUT] else false, [DATE DEBUT] + #duration(0,-7,0,0), Replacer.ReplaceValue, {"DATE DEBUT"} )

 

but  I got an error "unknown ID"

speedramps
Super User
Super User

We want to help but your description is very conufussing.
Please ask your manager or friends to help you write a clear description with example input data and desired output with a step by step description.

Poor descriptions waste your time and our time,

 

Here it is, a sample of what I said before;

fAllDayEventDATE DEBUTNew Column
FALSE17/11/2023 22:00:0017/11/2023 22:00:00
FALSE16/11/2023 22:00:0016/11/2023 22:00:00
TRUE24/11/2023 00:00:0024/11/2023 00:00:00
TRUE20/11/2023 00:00:0020/11/2023 00:00:00
TRUE01/11/2023 00:00:0001/11/2023 00:00:00
TRUE26/12/2023 00:00:0026/12/2023 00:00:00
TRUE01/01/2024 00:00:0001/01/2024 00:00:00
TRUE18/12/2023 00:00:0018/12/2023 00:00:00
TRUE01/11/2023 00:00:0001/11/2023 00:00:00
TRUE09/11/2023 00:00:0009/11/2023 00:00:00
FALSE10/11/2023 22:00:0010/11/2023 22:00:00
FALSE01/12/2023 17:00:0001/12/2023 17:00:00
FALSE26/12/2023 17:00:0026/12/2023 17:00:00
TRUE20/11/2023 00:00:0020/11/2023 00:00:00
TRUE17/11/2023 00:00:0017/11/2023 00:00:00
TRUE17/11/2023 00:00:0017/11/2023 00:00:00
TRUE01/12/2023 00:00:0001/12/2023 00:00:00
TRUE16/11/2023 00:00:0016/11/2023 00:00:00
TRUE10/11/2023 00:00:0010/11/2023 00:00:00
TRUE17/11/2023 00:00:0017/11/2023 00:00:00
TRUE25/12/2023 00:00:0025/12/2023 00:00:00
TRUE25/12/2023 00:00:0025/12/2023 00:00:00
TRUE24/11/2023 00:00:0024/11/2023 00:00:00
TRUE27/12/2023 00:00:0027/12/2023 00:00:00
TRUE03/11/2023 00:00:0003/11/2023 00:00:00
FALSE21/12/2023 22:00:0021/12/2023 22:00:00
FALSE01/12/2023 22:00:0001/12/2023 22:00:00

OK I will try to give more informations.

I speak about power query on power bi desktop.

I want to substract 7 hours to a date column [DATE DEBUT] when a condition is respected on an other column [fAllDayEvent].

I succeeded to do that in adding a new column this way =>

New Column = Table.AddColumn(#"Lignes filtrées3", "New Column", each if [fAllDayEvent] = "NO" then [DATE DEBUT] + #duration(0,-7,0,0) else [DATE DEBUT])

But I would prefer doing that on the  [DATE DEBUT] column itself without adding any other columns.

Is it possible?

Thanks.

 

Please provide example input data as table text (not a screen print) so we can import the data to build a solution for you.
Also provide the example desired output, with a clear description of the process flow.
Remember not to share private data ... we don't want you to get into trouble. 

You will get a quicker and better response if you put time, care and effort into writing clear problem descriptions.

Vaugue descriptions  waste your time and ourtime.

speedramps
Super User
Super User

We want to help you but your description is too vaugue. Please write it again clearly.

Please DON'T copy & paste your reports that does not work and expect us to fathom what you want to do. That is a bit crazy. 😀

Please just give a simple non technical functional decscription of what you want, then let us suggest the solution. Thank you.

Provide example input data as table text (not a screen print) so we can import the data to build a solution for you.
Also provide the example desired output, with a clear description of the process flow.
Remember not to share private data ... we don't want you to get into trouble. 😧
Take time and care to use the same table and field names in the input, output and description so we can understand your problem and help you.
Try keep it simple and ask one question per ticket.
You will get a quick response if you put time, care and effort into writing clear problem descriptions.

Vaugue descriptions can waste your time and ourtime.

Look foward to helping you when the above information is forthcoming

 

fAllDayEventDATE DEBUTNew Column
FALSE17/11/2023 22:00:0017/11/2023 22:00:00
FALSE16/11/2023 22:00:0016/11/2023 22:00:00
TRUE24/11/2023 00:00:0024/11/2023 00:00:00
TRUE20/11/2023 00:00:0020/11/2023 00:00:00
FALSE10/11/2023 22:00:0010/11/2023 22:00:00
FALSE01/12/2023 17:00:0001/12/2023 17:00:00
FALSE26/12/2023 17:00:0026/12/2023 17:00:00

 

So If I want to substract 7 hours to a date column [DATE DEBUT] I can do that with adding a NEW COLUMN

this way =>

New Column = Table.AddColumn(#"test", "New Column", each if [fAllDayEvent] = "FALSE" then [DATE DEBUT] + #duration(0,-7,0,0) else [DATE DEBUT])

But I would prefer doing that on the  [DATE DEBUT] column itself without adding any other columns.

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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