Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Pete230
Helper III
Helper III

Automatically format number as kWh; MWh; TWh depending on the value

Hi guys,

 

I would like to display Energy Data, for instance: 900 t. kWh -> 900 MWh

 

I want to check the value and use the next level unit (kWh, MWh, TWh) if the number exceeds 1,000.

Does anyone know how to do that or knows a work around?

 

Cheers, Pete

1 ACCEPTED SOLUTION
ichavarria
Solution Specialist
Solution Specialist

Hi @Pete230,

 

I would suggest you use the SWITCH function in a measure:

 

Energy Unit =
SWITCH(TRUE(),
SUM('Table'[Energy])<1000, "kWh",
SUM('Table'[Energy])<1000000, "MWh",
SUM('Table'[Energy])>=1000000, "TWh"
)

 

In this formula, we are checking the energy value using the Switch function, and then assigning the appropriate unit based on the value. If the energy value is less than 1000, we display it in kWh, if it is less than 1000000, we display it in MWh, and if it exceeds 1,000,000, we display it in TWh.

 

 

Best regards, 

Isaac Chavarria

If this post helps, then please consider Accepting it as the solution and giving Kudos to help the other members find it more quickly

 

View solution in original post

2 REPLIES 2
Pete230
Helper III
Helper III

Perfect, that was what I was looking for, thanks!

ichavarria
Solution Specialist
Solution Specialist

Hi @Pete230,

 

I would suggest you use the SWITCH function in a measure:

 

Energy Unit =
SWITCH(TRUE(),
SUM('Table'[Energy])<1000, "kWh",
SUM('Table'[Energy])<1000000, "MWh",
SUM('Table'[Energy])>=1000000, "TWh"
)

 

In this formula, we are checking the energy value using the Switch function, and then assigning the appropriate unit based on the value. If the energy value is less than 1000, we display it in kWh, if it is less than 1000000, we display it in MWh, and if it exceeds 1,000,000, we display it in TWh.

 

 

Best regards, 

Isaac Chavarria

If this post helps, then please consider Accepting it as the solution and giving Kudos to help the other members find it more quickly

 

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.