Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

powerbi hexadecimal

i want to calculate if the binary bits is enabled for the hexadecimal or not which is of 64 bits, for example if i give 0xffffffffffffffff then it should show value 64 bits is enabled. how to calcula...
  • Icey's avatar
    Icey
    5 years ago

    Hi Anonymous ,

     

    In Binary, a equals to 01100001, right?

     

    If so, try this:

    Column = 
    VAR Letter_ =
        DATATABLE (
            "Letters", STRING,
            "Binary_", STRING,
            {
                { "a", "01100001" },
                { "b", "01100010" },
                { "c", "01100011" }
            }
        )
    VAR Number_text = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }
    VAR t1 =
        ADDCOLUMNS (
            GENERATESERIES ( 1, LEN ( [String] ) ),
            "characters", RIGHT ( LEFT ( [String], [Value] ), 1 )
        )
    VAR t2 =
        ADDCOLUMNS (
            t1,
            "convert_",
                IF (
                    [characters] IN Number_text,
                    MOD ( TRUNC ( VALUE ( [characters] ) / 8 ), 2 )
                        & MOD ( TRUNC ( VALUE ( [characters] ) / 4 ), 2 )
                        & MOD ( TRUNC ( VALUE ( [characters] ) / 2 ), 2 )
                        & MOD ( VALUE ( [characters] ), 2 ),
                    MAXX ( FILTER ( Letter_, [Letters] = [characters] ), [Binary_] )
                )
        )
    RETURN
        CONCATENATEX ( t2, [convert_] )
    

     

     

    Best Regards,

    Icey

     

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