- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Convert kg, tons, lbs in new measure with Switch function
Dear Community,
I have a table which consists of 2 column with weight and respective weight units either KG or LB. And would like get help on DAX to create a new column measure which calculate all the weight in tonnes.
How can I have the solution in the following forms
1. using switch function to convert lbs and kgs into tonnes
2. use a reference table to get the solution and enable the users on the visual to toggle between tonnes and lbs
Product ID | Base Unit | produced quantity |
12345 | kg | 690 |
54321 | lb | 580 |
67890 | lb | 450 |
98765 | kg | 500 |
15983 | kg | 625 |
38951 | kg | 548 |
THe sample pbix file is saved in the following location.
Thanks for your attention and appreciate any help given.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @Chaithanya89 ,
There are several approaches to this problem. You can use SWITCH or field parameters. For the former, you need to create a disconnected table (without relationship to fact table) that will serve as holder of the switch measure. Please see sample DAX formulas below:
Base Unit Table =
DATATABLE ( "Unit", STRING, "Sort", INTEGER, { { "lbs", 1 }, { "tonnes", 2 } } )
lbs or tonnes =
SWITCH (
SELECTEDVALUE ( BaseUnit[Unit] ),
"lbs", [Quantity (lbs)],
"tonnes", [Quantity (tonnes)]
)
Please see attached pbix for the details
Dane Belarmino | Microsoft MVP | Proud to be a Super User!
Did I answer your question? Mark my post as a solution!
"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

I'm enable to updload a pbix for some reason - but please see link here to my google drive: https://drive.google.com/file/d/1fF-qCpz3HXZRLTkTlgHyjpr-H14JmuHn/view?usp=sharing
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

In Power BI, you can use the SWITCH function to convert between different units of weight, such as kilograms (kg), tons, and pounds (lbs). Here's an example of how you can use the SWITCH function:
Weight (New Measure) =
SWITCH(TRUE(),
'Table'[Unit] = "kg", 'Table'[Weight] * 2.20462, // Convert kg to lbs
'Table'[Unit] = "tons", 'Table'[Weight] * 2204.62, // Convert tons to lbs
'Table'[Unit] = "lbs", 'Table'[Weight], // Leave lbs as it is
BLANK() // Return blank for other units
)
Weight (New Measure) =
SWITCH(TRUE(),
'Table'[Unit] = "kg", 'Table'[Weight] * 2.20462, // Convert kg to lbs
'Table'[Unit] = "tons", 'Table'[Weight] * 2204.62, // Convert tons to lbs
'Table'[Unit] = "lbs", 'Table'[Weight], // Leave lbs as it is
BLANK() // Return blank for other units
)
In the above example, replace 'Table' with the actual name of your table, 'Unit' with the name of the column containing the unit of weight, and 'Weight' with the name of the column containing the weight values.
The SWITCH function checks the value of the 'Unit' column and performs the appropriate conversion based on the condition. It multiplies the 'Weight' column by the conversion factor to convert the weight to the desired unit.
Note that the conversion factors used in the example are approximate values. You may need to adjust them based on your specific conversion requirements.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Thanks a lot for your help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi Chaithanya
Another solution could be to create a many to many reference table which you join to the data table
Join using Base Unit to the main table:
If you create a filter based on "preffered unit" and set it to one selected value - this means that for every value of base unit, there is only one corresponding row in the rerference table.
The expression is then:
The advantage of this is more flexibility, should you wish to add more conversions.
Pi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

I'm enable to updload a pbix for some reason - but please see link here to my google drive: https://drive.google.com/file/d/1fF-qCpz3HXZRLTkTlgHyjpr-H14JmuHn/view?usp=sharing
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @Chaithanya89 ,
There are several approaches to this problem. You can use SWITCH or field parameters. For the former, you need to create a disconnected table (without relationship to fact table) that will serve as holder of the switch measure. Please see sample DAX formulas below:
Base Unit Table =
DATATABLE ( "Unit", STRING, "Sort", INTEGER, { { "lbs", 1 }, { "tonnes", 2 } } )
lbs or tonnes =
SWITCH (
SELECTEDVALUE ( BaseUnit[Unit] ),
"lbs", [Quantity (lbs)],
"tonnes", [Quantity (tonnes)]
)
Please see attached pbix for the details
Dane Belarmino | Microsoft MVP | Proud to be a Super User!
Did I answer your question? Mark my post as a solution!
"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
09-04-2024 02:10 AM | |||
05-24-2024 09:21 AM | |||
04-12-2023 03:11 PM | |||
06-17-2024 11:57 PM | |||
Anonymous
| 10-27-2017 01:40 PM |
User | Count |
---|---|
85 | |
78 | |
41 | |
40 | |
35 |