Forum Discussion

LizHackett's avatar
LizHackett
Regular Visitor
9 years ago
Solved

Calculate temperature celsius from fahrenheit

Hi all,

 

I'm new to DAX, and struggling to figure this measure.

 

We have a column of fahrenheit temperature and want to add an extra column with the corresponding Celsius, help!

 

  • Hi there you can create a new column with the following below.

     

    Celcius = ('Tablename'[Fahrenhiet]-32) * 0.5556

     

  • Hi LizHackett,

    I think you would add a new calculated column rather than a measure with the formula to convert; something like:

     

    Name_for_your_DegC_column = DIVIDE((Name_of_your_table[Name_of_your_column_with_DegF_values]-32)*5,9)

     

    HTH,
    Karl

     

  • Hi LizHackett,

     

    Either in Power Query you create a costum column with this formula as follow where my column with farhenheit data is named Fahren : ([Fahren]-32)*5/9

    Or in the Power Bi desktop, you create a column with the same formula ([Fahren]-32)*5/9

     

    Thx,

     

    Ninter

6 Replies

  • Hi there you can create a new column with the following below.

     

    Celcius = ('Tablename'[Fahrenhiet]-32) * 0.5556

     

  • Hi LizHackett,

    I think you would add a new calculated column rather than a measure with the formula to convert; something like:

     

    Name_for_your_DegC_column = DIVIDE((Name_of_your_table[Name_of_your_column_with_DegF_values]-32)*5,9)

     

    HTH,
    Karl

     

  • Hi LizHackett,

     

    Either in Power Query you create a costum column with this formula as follow where my column with farhenheit data is named Fahren : ([Fahren]-32)*5/9

    Or in the Power Bi desktop, you create a column with the same formula ([Fahren]-32)*5/9

     

    Thx,

     

    Ninter

  • LizHackett's avatar
    LizHackett
    Regular Visitor

    Thanks all, i got it to work in PowerBI desktop using (([Temp f]-32)*5/9))

    • KarlinOz's avatar
      KarlinOz
      Icon for Advocate III rankAdvocate III

      Good on you LizHackett. One tip I have learned is to use the Divide function rather than doing divisions manually. That way when there is an a divide by 0 error (not going to happen in this particular case but will in other scenarios) it is handled gracefully rather than generating an error on the row.

       

      So, instead of  x/y use Divide(x,y)

       

      HTH,
      Karl

  • Anonymous's avatar
    Anonymous
    Not applicable

    In case you need to go the other way from fahrenheit to celsius here is the formula I used:

    Temp (°F) = ([Temp (°C)] * 1.8) +32