Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hello, I´m using the following code:
#"Substract" = Table.AddColumn(MaxOfYear, "Diferencial aceite", each [MaxfYear] - [MinOfYear], type number)
To calculate the difference between the Max value and Min value from a column, but when the Min and Max is the same value I got 0 (obviusly), so I need to change the Min value to 0 so i get : MaxYfear - 0 = MaxfYear
How can I do this?
Solved! Go to Solution.
Hi @OscarSuarez10,
you can use if/then/else for it.
#"Substract" = Table.AddColumn(MaxOfYear, "Diferencial aceite", each if [MaxfYear] = [MinOfYear] then [MaxfYear] else [MaxfYear] - [MinOfYear], type number)
Or do I understand you wrong and you expect something like: IF MAX equals MIN then SET VALUE IN COLUMN "MIN" TO 0?
Hi @OscarSuarez10,
you can use if/then/else for it.
#"Substract" = Table.AddColumn(MaxOfYear, "Diferencial aceite", each if [MaxfYear] = [MinOfYear] then [MaxfYear] else [MaxfYear] - [MinOfYear], type number)
Or do I understand you wrong and you expect something like: IF MAX equals MIN then SET VALUE IN COLUMN "MIN" TO 0?
Hello @Nolock that solved my question thank you, now I have to use the same code to substract the production of the last year and the previous year last production like this: 1000 (feb-1-2021) - 700 (april-1-2020) = 300, can you help me ?
| Year | Production | Diferencial production 2019 | 300 | |
| jan-1-2019 | 100 | |||
| feb-1-2019 | 200 | |||
| march- 1- 2019 | 300 | Diferencial production 2020 | 500 | |
| april-1-2019 | 400 | |||
| jan-1-2020 | 200 | |||
| feb-1-2020 | 300 | Diferencial production 2021 | 300 | |
| march- 1- 2020 | 400 | |||
| april-1-2020 | 700 | |||
| feb-1-2021 | 1000 |
Hi @OscarSuarez10,
please create a new thread for a new topic. Especially if this thread is already closed.
And please try to write more examples that we know what you mean. Thank you very much 🙂
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 |
| User | Count |
|---|---|
| 8 | |
| 8 | |
| 6 | |
| 6 | |
| 5 |