Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
551 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Feeling in festive mood I thought I'd show you how to create a Christmas countdown using DAX.
The function I will need is DATEDIFF which shows the difference between two dates using the interval supplied.
The intervals available
To calculate the difference between today's date and Christmas day in days:
TODAY() gives the current date with a time of 12:00AM
I'm using the DATE function to ensure the correct date is used, avoiding any problems with UK/US date styles.
How about the difference in hours?
The NOW function returns the current date and time thus giving an accurate difference in hours
I can now repeat the expression above for minutes & seconds.
Simply change the interval to return the minutes and seconds figures
Now I have the differences it would be nice to show this as a string that I could maybe use in the card visual.
Note the use of variables for each difference which can then be used in the RETURN statement. The UNICHAR(10) is a Unicode character for a new line
Finally I'll wrap all this up in an IF. When it is not Christmas day the IF function should return the countdown but when the Santa has been it should return a Christmas message.
The finished measure with a nice message for Christmas day.
Before Christmas
Santa's been!
You can learn more about this topic on the following Wise Owl courses:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.