cancel
Showing results for
Did you mean:

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Helper II

## 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
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

2 REPLIES 2
Helper II

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

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

Announcements

#### Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

#### Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

#### The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors