Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
CONVERT THE ABOVE COLUMN TO DECIMAL VALUES WHICH ARE NOW IN HEXADECIMAL FORM, LIKE FOR EXAMPLE 0x40 should get value 64 ( by substitue 0x to space). I WANT ONLY IN DAX NOT IN POWER QUERY OR M.
Solved! Go to Solution.
Hi @Anonymous
Download example PBIX with code
Do you just need this conversion for 2 digit hex numbers? This code works only for 2 digits as shown in your example but can be expanded for more digits.
Firstly, create a new table
HexTable = {
("0", 0),
("1", 1),
("2", 2),
("3", 3),
("4", 4),
("5", 5),
("6", 6),
("7", 7),
("8", 8),
("9", 9),
("A", 10),
("B", 11),
("C", 12),
("D", 13),
("E", 14),
("F", 15)
}
Rename the text column Hex and the numeric column Decimal
Then create a column in your table containing the hex - change the VAR statements with 'Table'[Hex] to match your own table and column names.
HexToDecimal =
VAR _FirstHexDigit = RIGHT('Table'[Hex],1)
VAR _SecondHexDigit = MID('Table'[Hex],3,1)
RETURN
LOOKUPVALUE('HexTable'[Decimal],'HexTable'[Hex], _SecondHexDigit)*16 + LOOKUPVALUE('HexTable'[Decimal],'HexTable'[Hex], _FirstHexDigit)
Regards
Phil
Proud to be a Super User!
Hi @Anonymous
Download example PBIX with code
Do you just need this conversion for 2 digit hex numbers? This code works only for 2 digits as shown in your example but can be expanded for more digits.
Firstly, create a new table
HexTable = {
("0", 0),
("1", 1),
("2", 2),
("3", 3),
("4", 4),
("5", 5),
("6", 6),
("7", 7),
("8", 8),
("9", 9),
("A", 10),
("B", 11),
("C", 12),
("D", 13),
("E", 14),
("F", 15)
}
Rename the text column Hex and the numeric column Decimal
Then create a column in your table containing the hex - change the VAR statements with 'Table'[Hex] to match your own table and column names.
HexToDecimal =
VAR _FirstHexDigit = RIGHT('Table'[Hex],1)
VAR _SecondHexDigit = MID('Table'[Hex],3,1)
RETURN
LOOKUPVALUE('HexTable'[Decimal],'HexTable'[Hex], _SecondHexDigit)*16 + LOOKUPVALUE('HexTable'[Decimal],'HexTable'[Hex], _FirstHexDigit)
Regards
Phil
Proud to be a Super User!
Im still new to this power BI. Just one question how do i add another 2 digits to the Hexdec conversion syntex.
Example: d2da
Regards
Johan
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
94 | |
92 | |
83 | |
71 | |
49 |
User | Count |
---|---|
143 | |
120 | |
110 | |
60 | |
57 |