Age Calculation

Age Calculation in Power BI using Power Query

Power Query has a simple method to calculating the age. However, since DAX is the main language usedin numerous calculationsin Power BI, many do not know about this feature in Power Query. In this article, I'll show how simple it is to calculateAge within Power BI with Power BI. The methodis very beneficial when your estimation of your agecan be calculated on an earlier calculated row-by-row row basis.

Calculate Age from a date

Below, you will see the DimCustomer table, which is an integral part of the AdventureWorksDW table, which acts as an entry point for the birthday column. I've taken out a few of the columns that aren't needed in order to simplify the understand.

To calculate your age for each of your customers All you have to do is to:

  • In Power BI Desktop, Click on Transform Data
  • In the Power Query Editor window, select the first column, Birthdate.
  • Go to the Add Column Tab to the Column Tab, then select"Add Column Tab," then click on the "From Date & Time" section. Under Date, select the age range.

That's that. This is the method you calculate an amount which is the total of the column for Birthdate column, as well as the current date and time.

But, the age that appears in"Age" but, since it's under the Age column, but it doesn't appear to be a real age. This is because it's a real time period.

Duration

Duration is a specific type of data in Power Query which represents the differences between the two DateTime values. Duration is a mixture of four numbers:

days.hours.minutes.seconds

This is the way to take the information above into consideration. From the perspective of the user, it's not their responsibility to read the details of this. There are ways to make sure that every element is included in the time. When you select the duration menu you'll be able to get the amount of minutes and seconds as well as days, hours and years from it.

To assist in calculating the age in years like, for instance it is easy to hit the Total Year:

It is important to note that the duration is measured in days . Then, it is multiplied by days, to calculate the annual amount.

Rounding

There is no truth in it, and no person claims to be 53.813698630136983! They state 53, which is round down. It's easy to choose Rounding and then round down from the Transform tab.

This will tell you how old you are:

Then, you can clean the other columns, if you want (or maybe you've taken advantage of transformations by using the Transform tab, avoiding having the task of creating new columns) You can name this column: Age

Things to Know

  • Refresh The age that is calculated in this manner will be updated each time you are refreshing your information. Each time, it will compare the date of birth to the date and date at the time of refresh. This method is pre-calculating an age. If, however, you need the calculation to be performed dynamically using DAX, this is the way I explained the method that you can use.
  • The motivation for Power Query: Benefits of doing an age calculation with Power Query is that the calculation takes place when you refresh your report, and using an instrument which makes the calculation quicker and easier, and there is no additional overhead when calculating it using the DAX method to determine the time.
  • Alternative scenarios It cannot be utilized to calculate the age of a person based on their birth date. This can be used to calculate the age of inventory at the stock level and also the difference between dates and times from one another.

Video

REZA RAD

TRAINER, CONSULTANT, MENTORReza Rad is a Microsoft Regional Director, an Author, Trainer, Speaker and Consultant. He has a BSc in Computer engineering. He has more than 20 years old. experience in the area of data analysis, databases, BI, programming and development primarily in Microsoft technologies. He has been an official Microsoft Data Platform MVP for nine years in a row (from 2011 until the present) because of his love in Microsoft BI. Reza is an avid blogger as well as the co-founder and the editor for RADACAD. Reza is also the co-founder and co-organizer of Difinity Conference. Difinity Conference located in New Zealand.
His articles on different aspects of technologies, especially on MS BI, can be found on his blog: https://radacad.com/blog.
He has written a few books on MS SQL BI and also is working on additional books. He was also a frequent participant in forums online for technical issues like MSDN and Experts-Exchange and was moderator of the MSDN SQL Server forums, and holds an MCP and MCSE and an MCITP of Business Intelligence. He is the head of the New Zealand Business Intelligence users group. In addition, he is the author of the well-known publication Power BI from Rookie to Rock Star, which is free and contains more than 1750 pages of information and the Power BI Pro Architecture published by Apress.
Speakers are an International speaker at Microsoft Ignite, Microsoft Business Applications Summit, Data Insight Summit, PASS Summit, SQL Saturday, and SQL Users Groups. And He is a Microsoft Certified Trainer.
Reza's goal is to assist users find the most effective data solution. He is an avid Data enthusiast.This post was written by Reza in Power BI, Power BI from Rookie to Rockstar, Power Query and is categorized in Power BI, Power BI from Rookie to Rock Star, Power Query. This entry was filed under Power BI. This entry was posted in Power BI. Bookmark the permalink.

Post navigation

- Share different visual pages using different security groups in Power BIAge Calculation in Years which works for Leap Year in Power BI using Power Query

Comments

Popular posts from this blog

BMI Calculator

Durga Chalisa Lyrics in Hindi