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
Anonymous
Not applicable

How can I change values in a specific column depending on values of other columns?

Hi,

 

I created a duplicate of the column "Einzeldauer" and named it "Ersatzstunden". The column "Einzeldauer" must stay untouched.

 

1. If a cell in column "Grund Abwesend" is "Feiertag" and the cell in the column "Kommentar" contains "ÜÜ" then the value of the cell in the column "Ersatzstunden" should stay untouched.

2. If a cell in column "Grund Abwesend" is "Feiertag" and the cell in the column "Kommentar" contains "ÜÜN" then the value of the cell in the column "Ersatzstunden" must be multiplied by -1.

3. In any other case the value of the cell in the column "Ersatzstunden" should be "null".

 

 

original:

 

Peterman_0-1666252220259.png

 

expected result:

 

Peterman_1-1666252596479.png

 

Which formula would I have to enter into the Advanced Editor?

 

Many thanks for hints!

1 ACCEPTED SOLUTION
JorgePinho
Solution Sage
Solution Sage

Hello @Anonymous !

 

My suggestion is:

 

1. Delete the current Ersatzstunden column you have

2. Add Column > Custom Column and try this 

JorgePinho_0-1666255825529.png

 

if [Grund Abwesend] = "Feiertag" and Text.Contains([Kommentar], "ÜÜ") then [Einzeldauer]
else if [Grund Abwesend] = "Feiertag" and Text.Contains([Kommentar], "ÜÜN") then Value.Multiply([Einzeldauer],-1)
else null

View solution in original post

2 REPLIES 2
JorgePinho
Solution Sage
Solution Sage

Hello @Anonymous !

 

My suggestion is:

 

1. Delete the current Ersatzstunden column you have

2. Add Column > Custom Column and try this 

JorgePinho_0-1666255825529.png

 

if [Grund Abwesend] = "Feiertag" and Text.Contains([Kommentar], "ÜÜ") then [Einzeldauer]
else if [Grund Abwesend] = "Feiertag" and Text.Contains([Kommentar], "ÜÜN") then Value.Multiply([Einzeldauer],-1)
else null
Anonymous
Not applicable

Thank you very much. It works not as expected as the first "ÜÜ" already fulfills the "if" and so "ÜÜN" will never be identified. Once I changed "ÜÜ" to "ÜÜP" in my source files and changing the formula as follows ist works fine:

 

if [Grund Abwesend] = "Feiertag" and Text.Contains([Kommentar], "ÜÜP") then [Einzeldauer]
else if [Grund Abwesend] = "Feiertag" and Text.Contains([Kommentar], "ÜÜN") then Value.Multiply([Einzeldauer],-1)
else null

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors