Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
In my recent quest to create or catalog as many DAX equivalents for Excel functions , ARABIC converts numbers written in the Roman numeral system to numbers written in the Arabic numeral system, just in case you have to convert that EBCIDIC encoded mainframe data from those COBOL programs that store 2-digit years written as Roman numerals...
ARABIC =
VAR __Roman = MAX([ROMAN])
VAR __Classic =
DATATABLE(
"Arabic",INTEGER,
"Roman",STRING,
{
{ 1, "I" },
{ 4, "IV" },
{ 5, "V" },
{ 9, "IX" },
{ 10, "X" },
{ 40, "XL" },
{ 50, "L" },
{ 90, "XC" },
{ 100, "C" },
{ 400, "CD" },
{ 500, "D" },
{ 900, "CM" },
{ 1000, "M" }
}
)
VAR __Convert = __Classic
VAR __Table =
ADDCOLUMNS(
ADDCOLUMNS(
GENERATESERIES(1,LEN(__Roman),1),
"__Previous",[Value] - 1,
"__Next",[Value] + 1,
"__Roman",MID(__Roman,[Value],1)
),
"__Arabic",MAXX(FILTER(__Convert,[Roman] = [__Roman]),[Arabic])
)
VAR __Table1 =
ADDCOLUMNS(
ADDCOLUMNS(
ADDCOLUMNS(
__Table,
"__PreviousRoman",MAXX(FILTER(__Table,[Value] = EARLIER([__Previous])),[__Roman]),
"__NextRoman",MAXX(FILTER(__Table,[Value] = EARLIER([__Next])),[__Roman])
),
"__PreviousArabic",MAXX(FILTER(__Convert,[Roman] = [__PreviousRoman]),[Arabic]),
"__NextArabic",MAXX(FILTER(__Convert,[Roman] = [__NextRoman]),[Arabic])
),
"__Final",
SWITCH(TRUE(),
[__NextArabic] > [__Arabic],0,
[__PreviousArabic]<[__Arabic],[__Arabic]-[__PreviousArabic],
[__Arabic]
)
)
RETURN
SUMX(__Table1,[__Final])
eyJrIjoiOTU5NWZmODgtYmM2YS00OWQxLTgyNTEtM2IxZDRlODhiNjllIiwidCI6IjRhMDQyNzQzLTM3M2EtNDNkMi04MjdiLTAwM2Y0YzdiYTFlNSIsImMiOjN9