Forum Discussion

raima7's avatar
raima7
New Member
10 years ago
Solved

Function convert in Power BI

Hello everybody, :) I'm trying to assign my datas to a unit of measure (kgs, lbs, tons) and I would like to convert them. Someone would have any idea?   Thanks
  • Eric_Zhang's avatar
    10 years ago

    raima7

     

    Supposing there're trans and rates tables as below

     

    Create a measure as

    Total Mass =
    IF (
        ISFILTERED ( Rate[TO_UNIT] ) && HASONEVALUE ( Rate[TO_UNIT] ),
        SUMX ( Trans, Trans[AMOUNT] * LASTNONBLANK ( Rate[RATE], "" ) )
            & " "
            & LASTNONBLANK ( Rate[TO_UNIT], "" )
            & "s",
        SUMX ( Trans, Trans[AMOUNT] * LASTNONBLANK ( 'Default Rate'[RATE], "" ) )
            & " "
            & LASTNONBLANK ( 'Default Rate'[TO_UNIT], "" )
            & "s"
    )

    Then use a Slicer to determine the converting UNIT. By default, it shows as kgs.

     

    Choose lbs

     

    Choose tons

     

    Check more details in the attached pbix. If it answers your question, please accept it as solution. For any question, feel free to let me know. :)