Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

HEX2BIN

Hello Community,

 

I have a hex value as : 29 6A CC 69 D1 6C 5C 1B

and want to convert it to binary as: 0010100101101010110011000110100111010001011011000101110000011011.

 

I did my research but couldn't find a direct way to convert it, so i tried to convert from HEC2DEC (provides approx value) and then DEC2BIN (getting error "An argument of function 'MOD' has the wrong data type or the result is too large or too small."). Please let me know is there any direct way or if I can make ay changes in the  below attached dax codes:

HEX2DEC:

DEC2BIN:

 

Thanks in advance,

Saurav

4 Replies

  • daXtreme's avatar
    daXtreme
    Solution Sage

    Why don't you convert all your hex values in Power Query or in the source? DAX is not the best place to do it and as you can already see: it's awkward, to say the least.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    By my research, I'm afraid that we cannot convert hex to Binary directly in power bi by DAX.

    You'd better convert hex to number and then convert number to binary as a workaround.

    Here are two thread you could refer to.

    https://www.excelandpowerbi.com/?p=291

    https://community.powerbi.com/t5/Desktop/Number-to-Binary/m-p/235261#M104739

    https://xxlbi.com/blog/converting-hexadecimal-to-decimal-numbers-in-power-query/

     

    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.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello Anonymous ,

       

      Yes I've already solved the problem by converting Hex2Dec and then Dec2Bin.

      Thank you for replying.

       

      Regards,

      Saurav 

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

         

        I am so glad that you could solve your problem. Please kindly Accept the helpful reply as the solution. More people will benefit from it. 

         

        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.