Forum Discussion
abukapsoun
Post Patron
6 years agoMultiplying values
Hi, Need your support please. I have the following Table Reference P01 P02 X -1000 500 Y 800 -600 How can i transform the sign of values based on ...
- 6 years ago
Hi abukapsoun
There are 2 ways to do this.
- You can unpivot the columns, then create the new column with the IF function in DAX
- Or, you can create the IF function in Power Query Editor before unpivoting: Power Query > Add Column > Custom Column > Formula: if [Reference] = "X" then [P01]*-1 else [P01]
**Update: formula amended as needed
abukapsoun
Post Patron
6 years agoHi
I have created the new columns and it is working like a charm. However when I go to query editor to unpivot the columns, the newly created column does not appear in the table. I assume because they were created from a formula ? But then how can I unpivot them ?
I want to have them in the form of:
Thanks,
darentengmfs
Post Prodigy
6 years agoHi abukapsoun
There are 2 ways to do this.
- You can unpivot the columns, then create the new column with the IF function in DAX
- Or, you can create the IF function in Power Query Editor before unpivoting: Power Query > Add Column > Custom Column > Formula: if [Reference] = "X" then [P01]*-1 else [P01]
**Update: formula amended as needed
- abukapsoun6 years ago
Post Patron
I guess we are almost there,
I tried creating the formula:
IF [Reference] = "X" then [P01]*(-1) else [P01]
But I am getting the following error on P01: Token Eof expected.
Any idea?
- abukapsoun6 years ago
Post Patron
i changed IF to if and it worked 🙂 thanksss