Forum Discussion
Anonymous
5 years agoNot 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 calcula...
- 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.
Anonymous
5 years agoNot 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
5 years agoHi 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.