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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

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 calculate total no of enabled bits for each rowin TO_DSS_. USING #DAX NOT POWER QUERRY PLEASE

 

Capture.PNG.

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

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_] )

binary.JPG

 

 

Best Regards,

Icey

 

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

4 REPLIES 4
PhilipTreacy
Super User
Super User

Hi @Anonymous 

Do you want a decimal number e.g. 64 or do you want the binary representation of FFFFFFFFFFFFFFFF ?

I don't understand if you want an answer for each column containing binary i.e. 3 separate answers for the table shown above, or just fo a particular column? What do you mean by calculate total number of enabled bits for each row?

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Sorry i want to convert each string into binary. like 6307a should give me 01100011000001111100. just conver each char to binary. iam tring to use substitute but it is not working.

Icey
Community Support
Community Support

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_] )

binary.JPG

 

 

Best Regards,

Icey

 

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

Anonymous
Not applicable

I want to calculate how many binary set bits are enabled(ON or OFF) for first and last columns. for example if i take first column value 0x603...... for this value i want to know how many set bits are enabled in whole number between 0 to 64. 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors