Calendar in DAX, Power BI

As a Power BI developer, more than often you’ll likely need to track trends over time. It goes without saying that at some point you will be engaging with a calendar.

In DAX, you can easily create a calendar table with all the features of a calendar y…


This content originally appeared on DEV Community and was authored by John Kyalo

As a Power BI developer, more than often you'll likely need to track trends over time. It goes without saying that at some point you will be engaging with a calendar.

In DAX, you can easily create a calendar table with all the features of a calendar you need, may it be Quarters in a year or month numbers.

We will explore creating a calendar table :

The first step is specifying the range of dates you want your calendar to contain and you can contain that in variables. You will need to have a calendar that includes the dates present in your calendar

dimCalendar =
VAR Mindate = MIN(Expenditure[Date]
VAR Maxdate = TODAY()
RETURN
ADDCOLUMNS(
CALENDAR(Mindate, Maxdate),
"YEAR" YEAR([Date]),
"MONTH" MONTH([Date]),
"DAY" DAY([Date]),
"MONTHNAME" FORMAT([Date], "MMM"),
"QUARTER", "Q" & QUARTER([Date])
)

The above is a simple calendar that:

  1. Defines the dates you need in your calendar table as variables
  2. You need to ADDCOLUMNS to the calendar, and begin by having it said that the calenda will contain the mindate and the maxdate. 3.Specify the columns as needed. Whatever we have in quotation, is the name of the column then returns respective value.
  3. The format in the Monthname ensure we return our months as 'Jan, Feb' simply as 3 letter words.
  4. For the Quarter column, the additional Q ensures the name of quarters begin with the prefix Q. This way it adds much more sense.

There you go, try out this simple calendar and use it in your reports.

Anything and Everythind Data!


This content originally appeared on DEV Community and was authored by John Kyalo


Print Share Comment Cite Upload Translate Updates
APA

John Kyalo | Sciencx (2024-11-12T03:28:38+00:00) Calendar in DAX, Power BI. Retrieved from https://www.scien.cx/2024/11/12/calendar-in-dax-power-bi/

MLA
" » Calendar in DAX, Power BI." John Kyalo | Sciencx - Tuesday November 12, 2024, https://www.scien.cx/2024/11/12/calendar-in-dax-power-bi/
HARVARD
John Kyalo | Sciencx Tuesday November 12, 2024 » Calendar in DAX, Power BI., viewed ,<https://www.scien.cx/2024/11/12/calendar-in-dax-power-bi/>
VANCOUVER
John Kyalo | Sciencx - » Calendar in DAX, Power BI. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/11/12/calendar-in-dax-power-bi/
CHICAGO
" » Calendar in DAX, Power BI." John Kyalo | Sciencx - Accessed . https://www.scien.cx/2024/11/12/calendar-in-dax-power-bi/
IEEE
" » Calendar in DAX, Power BI." John Kyalo | Sciencx [Online]. Available: https://www.scien.cx/2024/11/12/calendar-in-dax-power-bi/. [Accessed: ]
rf:citation
» Calendar in DAX, Power BI | John Kyalo | Sciencx | https://www.scien.cx/2024/11/12/calendar-in-dax-power-bi/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.