Display the last value that is greater than zero and not unknown

Which “same sensor”? The one in the post to which you are replying is an energy sensor (Wh or kWh) not a power sensor (W or kW).

Paste in the correctly-formatted code for the sensor you have. I suspect the answer will be as simple as “delete the / 1000” but need to see your code to be sure.