Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
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
.
Solved! Go to Solution.
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.
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
Proud to be a Super User!
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.
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.
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.