I'm also late, but here's another solution for folks who are dealing with colors stored as integers that you need converted to hex for HTML elements. The two suggestions given work already, but face problems if you're working with values that don't take up all 6 spaces. The With statement on the outside is just for demo purposes, and you can remove it if you don't need it.
With(
{color:16777215}, // white
Concat(
ForAll(
[RoundDown(color/65536,0),RoundDown(Mod(color,65536)/256,0),RoundDown(Mod(Mod(color,65536),256),0)] As ColorPart,
Concat(
ForAll(
[RoundDown(ColorPart.Value/16,0),RoundDown(Mod(ColorPart.Value,16),0)],
With({a: Mod(ThisRecord.Value,16)},
{hex:If(a<10,Text(a),Switch(a,10,"A",11,"B",12,"C",13,"D",14,"E","F"))}
)
),
hex&""
)
),
Value
)
)
If your data source has a different configuration, like Delphi (which uses BBGGRR instead of RRGGBB), you can just change the order of the elements in the OrderPart array (and if you want RGBA instead, just use the array parts as your RGB portion and set A to whatever you want).
[RoundDown(Mod(Mod(color,65536),256),0),RoundDown(Mod(color,65536)/256,0),RoundDown(color/65536,0)] As ColorPart // BBGGRR version