Last active
September 3, 2025 01:35
-
-
Save cbaragao/d37afc19633cbed8972ef287f5e3325d to your computer and use it in GitHub Desktop.
Dynamically show a process of dates using DAX
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
| Chevron Timeline = | |
| // Assume you have a table with columns: ProcessName, ProcessDate | |
| // Example virtual table (replace with your actual table reference) | |
| VAR ProcessTable = | |
| DATATABLE( | |
| "Order", INTEGER, // Ensure order column starts with 1 (first date) and sequentially puts dates in order | |
| "ProcessName", STRING, | |
| "ProcessDate", DATETIME, | |
| { | |
| {4,"End Date", "2025-03-31"}, | |
| {3,"Approval Date", "2025-04-10"}, | |
| {2,"Review Date", BLANK()}, | |
| {1,"Start Date", "2025-01-01"} | |
| } | |
| ) | |
| VAR ChevronCount = COUNTROWS(ProcessTable) | |
| VAR BaseWidth = 160 // Space between chevrons | |
| VAR TotalWidth = 20 + (ChevronCount * BaseWidth) + 40 // Left margin + chevrons + right margin | |
| VAR Header = "<svg width=" & TotalWidth & """ height=""120"" viewBox=""0 0 " & TotalWidth & " 120"" xmlns=""http://www.w3.org/2000/svg"">" | |
| VAR Footer = "</svg>" | |
| VAR ChevronDefs = | |
| "<defs> | |
| <polygon id=""chevron-filled"" points=""0,0 140,0 180,40 140,80 0,80 40,40"" fill=""%FILL_COLOR%""/> | |
| </defs>" | |
| VAR AllChevrons = | |
| CONCATENATEX( | |
| ADDCOLUMNS( | |
| ProcessTable, | |
| "XPosition",([Order] - 1) * BaseWidth, | |
| "FillColor", IF(ISBLANK([ProcessDate]), "#D3D3D3", "#2D5A6B"), | |
| "TextColor", IF(ISBLANK([ProcessDate]), "black", "white"), | |
| "DisplayDate", IF(ISBLANK([ProcessDate]), "TBD", FORMAT([ProcessDate], "MM/DD/YYYY")) | |
| ), | |
| "<g transform=""translate(" & [XPosition] & ", 20)""> | |
| <polygon points=""0,0 140,0 180,40 140,80 0,80 40,40"" fill=""" & [FillColor] & """/> | |
| <text x=""90"" y=""25"" text-anchor=""middle"" font-family=""Arial, sans-serif"" font-size=""14"" font-weight=""bold"" fill=""" & [TextColor] & """>" & [ProcessName] & "</text> | |
| <text x=""90"" y=""55"" text-anchor=""middle"" font-family=""Arial, sans-serif"" font-size=""12"" fill=""" & [TextColor] & """>" & [DisplayDate] & "</text> | |
| </g>", | |
| "", | |
| [ProcessName], ASC | |
| ) | |
| VAR Output = Header & AllChevrons & Footer | |
| RETURN Output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment