Created
          March 6, 2023 16:35 
        
      - 
      
- 
        Save Hugoberry/31464e85b4ff412710834916e99d2467 to your computer and use it in GitHub Desktop. 
    DAX measure that formats a measure `[Quantity]` into a roman numeral
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    | Brand | Quantity | Roman Quantity | |
|---|---|---|---|
| A. Datum | 6897 | V̅I̅DCCCXCVII | |
| Adventure Works | 10901 | X̅CMI | |
| Contoso | 53151 | L̅MMMCLI | |
| Fabrikam | 10973 | X̅CMLXXIII | |
| Litware | 10130 | X̅CXXX | |
| Northwind Traders | 2311 | MMCCCXI | |
| Proseware | 9322 | I̅X̅CCCXXII | |
| Southridge Video | 14866 | X̅I̅V̅DCCCLXVI | |
| Tailspin Toys | 10590 | X̅DXC | |
| The Phone Company | 4343 | I̅V̅CCCXLIII | |
| Wide World Importers | 6696 | V̅I̅DCXCVI | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Roman Quantity = | |
| CONCATENATEX ( | |
| ADDCOLUMNS ( | |
| ADDCOLUMNS ( | |
| GENERATESERIES ( 0, FLOOR ( LOG ( [Quantity], 10 ), 1 ) ), | |
| //number of digits | |
| "Digits", | |
| FLOOR ( | |
| MOD ( [Quantity], POWER ( 10, [Value] + 1 ) ) | |
| / POWER ( 10, [Value] ), | |
| 1 | |
| ) | |
| ), | |
| "ROMAN", LOOKUPVALUE ( Roman[Numeral], Roman[Index], [Digits] * POWER ( 10, [Value] ) ) | |
| ), | |
| [ROMAN], | |
| , | |
| [Value], 0 | |
| ) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Roman = | |
| DATATABLE ( | |
| "Index", INTEGER, | |
| "Numeral", STRING, | |
| { | |
| { 1, "I" }, | |
| { 2, "II" }, | |
| { 3, "III" }, | |
| { 4, "IV" }, | |
| { 5, "V" }, | |
| { 6, "VI" }, | |
| { 7, "VII" }, | |
| { 8, "VIII" }, | |
| { 9, "IX" }, | |
| { 10, "X" }, | |
| { 20, "XX" }, | |
| { 30, "XXX" }, | |
| { 40, "XL" }, | |
| { 50, "L" }, | |
| { 60, "LX" }, | |
| { 70, "LXX" }, | |
| { 80, "LXXX" }, | |
| { 90, "XC" }, | |
| { 100, "C" }, | |
| { 200, "CC" }, | |
| { 300, "CCC" }, | |
| { 400, "CD" }, | |
| { 500, "D" }, | |
| { 600, "DC" }, | |
| { 700, "DCC" }, | |
| { 800, "DCCC" }, | |
| { 900, "CM" }, | |
| { 1000, "M" }, | |
| { 2000, "MM" }, | |
| { 3000, "MMM" }, | |
| { 4000, "I̅V̅" }, | |
| { 5000, "V̅" }, | |
| { 6000, "V̅I̅" }, | |
| { 7000, "V̅I̅I̅" }, | |
| { 8000, "V̅I̅I̅I̅" }, | |
| { 9000, "I̅X̅" }, | |
| { 10000, "X̅" }, | |
| { 20000, "X̅X̅"}, | |
| { 30000, "X̅X̅X̅"}, | |
| { 40000, "X̅L̅"}, | |
| { 50000, "L̅"}, | |
| { 60000, "L̅X̅"}, | |
| { 70000, "L̅X̅X̅"}, | |
| { 80000, "L̅X̅X̅X̅"}, | |
| { 90000, "C̅X̅"}, | |
| { 100000, "C̅"}, | |
| { 200000, "C̅C̅"}, | |
| { 300000, "C̅C̅C̅"} | |
| } | |
| ) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment