Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hola estoy tratando de convertir código binario de 24 bits a hexadecimal
Una fórmula como esta funcionó en Excel usando el Bin2Hex
"RIGHT("0"&BIN2HEX(LEFT(A1,LEN(A1)/3)),2)&RIGHT("0"&BIN2HEX(MID(A1,LEN(A1)/3+1,1,3 LEN(A1)/3)),2)&RIGHT("0"&BIN2HEX(MID(A1,2*LEN(A1)/3+1,LEN(A1)/3)),2)
Un ejemplo 1100000001110011111110 debe ser C059DE
Solved! Go to Solution.
@Pandadev, si es binario no prueba, tiene código en Power Query/ M
recomienda
https://community.powerbi.com/t5/Desktop/Converting-Binary-to-hex-value-or-numeric-value/td-p/374779
Para DAX, consulte
https://dax.tips/2019/10/02/dax-base-conversions/
Hola, @Pandadev
Tengo un método complicado, si no crees que estorpe, puedes probarlo:
Necesita usar la columna condicional para convertir "4 bit binario" a "1bit hex", luego combinarlos.
Consulta M:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI0NIAAQwMQ09AQRAMJpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Index = _t, #"24bit binary" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"24bit binary", type text}, {"Index", type text}}),
#"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "24bit binary", "24bit binary - Copy"),
#"Split Column by Position" = Table.SplitColumn(#"Duplicated Column", "24bit binary - Copy", Splitter.SplitTextByRepeatedLengths(4), {"4bit binary - 1", "4bit binary - 2", "4bit binary - 3", "4bit binary - 4", "4bit binary - 5", "4bit binary - 6"}),
#"Unpivoted Columns2" = Table.UnpivotOtherColumns(#"Split Column by Position", {"Index", "24bit binary"}, "Attribute", "Value"),
#"Added Conditional Column" = Table.AddColumn(#"Unpivoted Columns2", "1 bit HEX ", each if [Value] = "0000" then 0 else if [Value] = "0001" then 1 else if [Value] = "0010" then 2 else if [Value] = "0011" then 3 else if [Value] = "0100" then 4 else if [Value] = "0101" then 5 else if [Value] = "0110" then 6 else if [Value] = "0111" then 7 else if [Value] = "1000" then 8 else if [Value] = "1001" then 9 else if [Value] = "1010" then "A" else if [Value] = "1011" then "B" else if [Value] = "1100" then "C" else if [Value] = "1101" then "D" else if [Value] = "1110" then "E" else if [Value] = "1111" then "F" else null),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Conditional Column",{{"1 bit HEX ", type text}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Value"}),
#"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Attribute]), "Attribute", "1 bit HEX "),
#"Merged Columns" = Table.CombineColumns(#"Pivoted Column",{"4bit binary - 1", "4bit binary - 2", "4bit binary - 3", "4bit binary - 4", "4bit binary - 5", "4bit binary - 6"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged")
in
#"Merged Columns"
Para obtener más detalles, por favor chech el archivo de ejemplo.
Saludos
Equipo de soporte de la comunidad _ Eason
@Pandadev, si es binario no prueba, tiene código en Power Query/ M
recomienda
https://community.powerbi.com/t5/Desktop/Converting-Binary-to-hex-value-or-numeric-value/td-p/374779
Para DAX, consulte
https://dax.tips/2019/10/02/dax-base-conversions/
He probado esta solución dax , pero viene con un error . He convertido el número largo binario de texto a decimal , trató de convertirlo a binario, donde sólo va a binario naranja, pero seguir recibiendo un MOD tiene un tipo de datos incorrecto o el resultado es demasiado grande
GENERATESERIES ( 1, 6 ) debe ser hasta 8 o 16
Mi consejo sería usar la forma de consulta de energía. Todas las formas DAx son un poco complejas.
He probado el código M para MODE S , que es el texto binario convertido a bin
• Table.AddColumn(-"Changed Type2", "Mode S Bin", each Binary.ToText([Mode S Binary])) convierte de nuevo al texto correctamente
• Table.AddColumn(-"Changed Type2", "Mode S Hex", each BinaryEncoding.Hex([Mode S Binary])) cuando probé esto sólo trae de vuelta el error
Hola, @Pandadev
Tengo un método complicado, si no crees que estorpe, puedes probarlo:
Necesita usar la columna condicional para convertir "4 bit binario" a "1bit hex", luego combinarlos.
Consulta M:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI0NIAAQwMQ09AQRAMJpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Index = _t, #"24bit binary" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"24bit binary", type text}, {"Index", type text}}),
#"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "24bit binary", "24bit binary - Copy"),
#"Split Column by Position" = Table.SplitColumn(#"Duplicated Column", "24bit binary - Copy", Splitter.SplitTextByRepeatedLengths(4), {"4bit binary - 1", "4bit binary - 2", "4bit binary - 3", "4bit binary - 4", "4bit binary - 5", "4bit binary - 6"}),
#"Unpivoted Columns2" = Table.UnpivotOtherColumns(#"Split Column by Position", {"Index", "24bit binary"}, "Attribute", "Value"),
#"Added Conditional Column" = Table.AddColumn(#"Unpivoted Columns2", "1 bit HEX ", each if [Value] = "0000" then 0 else if [Value] = "0001" then 1 else if [Value] = "0010" then 2 else if [Value] = "0011" then 3 else if [Value] = "0100" then 4 else if [Value] = "0101" then 5 else if [Value] = "0110" then 6 else if [Value] = "0111" then 7 else if [Value] = "1000" then 8 else if [Value] = "1001" then 9 else if [Value] = "1010" then "A" else if [Value] = "1011" then "B" else if [Value] = "1100" then "C" else if [Value] = "1101" then "D" else if [Value] = "1110" then "E" else if [Value] = "1111" then "F" else null),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Conditional Column",{{"1 bit HEX ", type text}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Value"}),
#"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Attribute]), "Attribute", "1 bit HEX "),
#"Merged Columns" = Table.CombineColumns(#"Pivoted Column",{"4bit binary - 1", "4bit binary - 2", "4bit binary - 3", "4bit binary - 4", "4bit binary - 5", "4bit binary - 6"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged")
in
#"Merged Columns"
Para obtener más detalles, por favor chech el archivo de ejemplo.
Saludos
Equipo de soporte de la comunidad _ Eason
Gracias , esa solución funcionó muy bien
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
1 |