Forum Discussion

wujunmin's avatar
wujunmin
Advocate III
4 years ago

Custom Calendar Visual by DAX

First, creat a calendar table:

Calendar = 
ADDCOLUMNS(CALENDAR(DATE(2021,1,1),DATE(2021,12,31)),
    "Month",MONTH([Date]),
    "Day",DAY([Date]),
    "DDD",FORMAT([Date],"DDD"),
    "WeekDay",WEEKDAY([Date],2),
    "WeekNum",WEEKNUM([Date],2) 
)

Then, creat a svg measure, mark it as  image url: 

SVG_DAY = 
"data:image/svg+xml;utf8,"&"
<svg xmlns='http://www.w3.org/2000/svg' height='100' width='100'>"&
    IF(SELECTEDVALUE('Calendar'[Date])=TODAY(),"<circle cx='50' cy='50' r='40' fill='Tomato'/>",BLANK())&"
    <text x='50' y='50' font-size='30' text-anchor='middle' dominant-baseline='middle' fill='"&
        IF(SELECTEDVALUE('Calendar'[Date])=TODAY(),"White",IF(SELECTEDVALUE('Calendar'[WeekDay])>=6,"Grey","Black"))&"'>"&SELECTEDVALUE('Calendar'[Day])&"
    </text>
</svg> " 

Finally, a matrix:

 

No RepliesBe the first to reply