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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

price per unit with mixed UOM (liters/gallons)

I am capturing data for prices of products. The issue I am having is that the units of measure (UOM) are different around the world. I need to be able to convert price per liter to price per gallon and vice versa, so that a slicer can be applied for the relevant UOM.

 

Prices are all in USD, so at least this does not need to be converted. 

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous ,

 

As far as I know, the convert between liters and gallons should be 1 L = 0.26 gal.

I think you can refer to my sample.

Data table:

RicoZhou_0-1674026858029.png

Unit:

RicoZhou_1-1674026874346.png

Measure:

Price convert(liters/gallons) =
VAR _SELECTUNIT =
    SELECTEDVALUE ( Unit[Unit] )
VAR _PRICE =
    CALCULATE ( SUM ( 'Table'[Price per unit] ) )
VAR _CONVERT =
    IF (
        SELECTEDVALUE ( 'Table'[Unit] ) = _SELECTUNIT,
        _PRICE,
        IF ( _SELECTUNIT = "liters", _PRICE / 0.26, _PRICE * 0.26 )
    )
RETURN
    IF ( ISFILTERED ( Unit[Unit] ), _CONVERT, BLANK () )

Result is as below.

RicoZhou_2-1674026908578.png

RicoZhou_3-1674026916504.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous ,

 

As far as I know, the convert between liters and gallons should be 1 L = 0.26 gal.

I think you can refer to my sample.

Data table:

RicoZhou_0-1674026858029.png

Unit:

RicoZhou_1-1674026874346.png

Measure:

Price convert(liters/gallons) =
VAR _SELECTUNIT =
    SELECTEDVALUE ( Unit[Unit] )
VAR _PRICE =
    CALCULATE ( SUM ( 'Table'[Price per unit] ) )
VAR _CONVERT =
    IF (
        SELECTEDVALUE ( 'Table'[Unit] ) = _SELECTUNIT,
        _PRICE,
        IF ( _SELECTUNIT = "liters", _PRICE / 0.26, _PRICE * 0.26 )
    )
RETURN
    IF ( ISFILTERED ( Unit[Unit] ), _CONVERT, BLANK () )

Result is as below.

RicoZhou_2-1674026908578.png

RicoZhou_3-1674026916504.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.