Forum Discussion

sy898661's avatar
sy898661
Helper V
8 years ago
Solved

Order dates by current month

Hello!   I have a table that contains the following columns [Date of Request, Request Description], and I am trying to create a column chart with Number of Requests per Month.   The dates range f...
  • edhans's avatar
    8 years ago

    To do it correctly, you really do need a date table. You always should have a date table in your model if you want to do anything by date, like a chart by months.

     

    To create a simple table, that should work for you:

    • Go to the Modeling tab and press New Table. Type the formula below. Change the dates to suit your needs. SHould be a least the first and last date in your mode.
    • Calendar = CALENDAR(DATE(2017,1,1), DATE(2018,12,31)
      You may want to format it as a pure date from the modeling tab, Formatting section. By default it has date and time.
    • Now click on the data table icon (far left) in Power BI Desktop, and select your Calendar datable.
    • Add a new column. Modeling tab, New Column. Type the below function.
    • Month = MONTH('Calendar'[Date])
    • Now go to the Relationships icon (again, far left of PBI window) and join the Date column in the Calendar table to the date column in your data table.
    • Put the MOnth column in the bar chart for the months, and your data from your data table.

     

    There is more if you want something like Jan, Feb, Mar, or January, February, March, etc. but that should get you started. For example:

    Short Month Name = FORMAT('Calendar'[Date],"MMM")

    would be the column to add to the date table to have Jan, Feb, Mar available.