SORTING MONTHS CHRONOLOGICALLY IN POWERBI?DESKTOP

SORTING MONTHS CHRONOLOGICALLY IN POWERBI?DESKTOP

  • Early last week, I was faced with a challenge while using Powerbi. The data I was asked to work on had a column that listed the names of months in the year. While I was done creating dashboards for the dataset, the dashboard didn’t make sense because the months could not be sorted chronologically. I tried sorting the axis by the month axis, but it didn’t work.
  • One of the major challenge I had was the fact that the column that had the months were not in date format. They were in text format and they couldn’t be converted which made it a little bit difficult.
  • After research, I found a solution which I’ll be writing about in today’s blog.
  • The first thing to do is to go to your loaded dataset under the fields tab in Powerbi. Click on the three dots near the dataset name and click on Edit query. Once this is done, the Power Query Editor will be opened.

No alt text provided for this image

  • In the Power Query Editor, click on the Add Column tab and click on Custom Column. A dialog box will be opened to add the name of the new column and the column formula. The whole essence of this step is to convert the original month column datatype from text to date.

No alt text provided for this image

  • In my case, I named the new column Dummy Date. The custom column formula will then be written as: “1 ” & [Month] & ” 2022” as shown below.

No alt text provided for this image
PICTURE DEPICTING THE CUSTOM COLUMN FORMULA

N.B: The Month in the formula above should be the name of the column with the month attributes in your dataset. I used Month because the name of the column is Month.

  • Click on OK after this. A new column showing date will be created as shown below.

No alt text provided for this image
PICTURE SHOWING THE CREATED DUMMY DATE COLUMN

  • The next step is to convert the new column data type to date format. After this is done, follow the step above to create another custom column. Once the dialog box opens, add the new column name and formula which will be different from the first one.?
  • In my case, I named the new column Month Number. The custom column formula will then be written as: Date.Month([Dummy Date]) as shown below.

No alt text provided for this image
PICTURE DEPICTING THE CUSTOM COLUMN FORMULA

  • Click on OK after this. A new column showing the calculated month number will be created. After this, change the data type of the Month Number column to Whole Number as shown below.

No alt text provided for this image
PICTURE SHOWING THE CREATED MONTH NUMBER COLUMN

N.B: The Dummy Date in the formula above should be the name of the first custom column that was created which was Dummy Date in my case.

  • You can then delete the first custom column created as it won’t be needed anymore. Right click on the column and click on Remove to delete it. After this, go to the Home tab and click on Close & Apply.
  • Once it’s loaded with the changes applied, click on the chart you want to sort by months chronologically, go to the data pane at left of the visual.

No alt text provided for this image

N.B: Once this is done, make sure to confirm that you click the dataset that is associated with the chart you want to sort by the right side of the opened tab. This is important most especially when you have many datasets with similar columns in the same workbook. For example, if you click another dataset not associated with the chart, it won’t be sorted even though the whole process above has also been done on that dataset.

  • After the above has been confirmed, click the month column header, under the column tools tab, click on the sort dropdown and click on Month Number as seen below and go back to the Report pane at the left of the tab (where your visual is). Automatically, the months will be sorted.

No alt text provided for this image
PICTURE SHOWING THE SORT DROPDOWN


No alt text provided for this image
MONTHS SORTED CHRONOLOGICALLY
Folashade Adeagbo

Data Analyst || Freelancer || Writer || Virtual Assistant || Data Science in view||

2 å¹´

Good work Mary

赞
回复
Mumuni JIMOH

Investment Banking || Data and Financial Analytics || Capital Market

2 å¹´

This is insightful. Kudos

赞
回复

要查看或添加评论,请登录

Mary Bajisma Ashiru的更多文章

  • HOW I REVOLUTIONIZED FOOD COOKING AND PIONEERED FOOD?ANALYSIS

    HOW I REVOLUTIONIZED FOOD COOKING AND PIONEERED FOOD?ANALYSIS

    Late last year (2024), driven by my passion for great cuisine, I enrolled in Hilda Baci’s renowned “Home to Pro Cooking…

    2 条评论
  • EMPLOYERS/HIRING MANAGERS EXPLOITING JOB APPLICANTS

    EMPLOYERS/HIRING MANAGERS EXPLOITING JOB APPLICANTS

    Hello readers, Today’s article discusses how some employers and hiring managers use job applicants to complete tasks…

    8 条评论
  • MY EXPERIENCE LANDING INTERNSHIPS AND JOBS AS A DATA ANALYST

    MY EXPERIENCE LANDING INTERNSHIPS AND JOBS AS A DATA ANALYST

    In today’s blog, you will be reading about my personal experience in the data analytics journey so far. The aim of this…

    10 条评论
  • AN ANALYSIS OF A FICTITIOUS DATA FROM QUICKCHECK

    AN ANALYSIS OF A FICTITIOUS DATA FROM QUICKCHECK

    In today’s article, I’ll be writing about the analysis I derived from a fictitious dataset from QuickCheck. This…

    2 条评论
  • Tutoring as a Data Analyst and Introduction to BAJISMALYTICS

    Tutoring as a Data Analyst and Introduction to BAJISMALYTICS

    Hello followers and newly subscribed followers, it’s been a minute of writing. Happy New Year to you all, I pray that…

  • SIX MONTHS WORKING ONSITE AS A BUSINESS ANALYST

    SIX MONTHS WORKING ONSITE AS A BUSINESS ANALYST

    Good day Data enthusiasts, It has been a while. In this blog, I’ll be writing a summary of some of the things I have…

  • POWER QUERY AUTOMATION WITH MICROSOFT EXCEL

    POWER QUERY AUTOMATION WITH MICROSOFT EXCEL

    Have you ever thought of designing a Microsoft Excel workbook template and using that particular template for a…

    2 条评论
  • WHAT-IF ANALYSIS IN MICROSOFT EXCEL (GOAL SEEK AND DATA TABLE)

    WHAT-IF ANALYSIS IN MICROSOFT EXCEL (GOAL SEEK AND DATA TABLE)

    In today’s blog, I’ll be writing on how to use and apply two of the what-if analysis options in Microsoft Excel. The…

    2 条评论
  • EMBEDDING POWER BI REPORT TO THE WEB

    EMBEDDING POWER BI REPORT TO THE WEB

    Some months ago, when I started using Power BI for data visualizations, I found it not possible to publish my reports…

    8 条评论
  • ROAD TRANSPORT CLASHES ANALYSIS (NIGERIA)

    ROAD TRANSPORT CLASHES ANALYSIS (NIGERIA)

    In today’s article, I’ll be analyzing the “Highway Accidents in Nigeria (Q2) 2020” data which I got from Kaggle. The…

社区洞察

其他会员也浏览了