Age Calculation in Power BI using Power Query

Power Query has a simple method of calculating the age. But, as DAX is the most widely used language usedin several calculationsin the Power BI platform, a lot of people don't have any idea about this function in Power Query. In this blog post I will demonstrate how easy to calculateAge in Power BI using Power BI. This methodis very beneficial when the computation of an agecan be conducted in a row-by-row basis.

Calculate Age from a date

The table is called the DimCustomer table that is part of the AdventureWorksDW table which as an age column. I've taken out some columns that aren't necessary in order to make it easier to read;

To calculate the exact age every purchaser, the following information is required:

  • In Power BI Desktop, Click on Transform Data
  • In the Power Query Editor window; pick the Birthdate column first.
  • Click on the Add Column Tab. Under the "From Date & Time" section, and under Date, choose the age range.

This is all there is to it. This will calculate the amount which is the sum that is the sum of Birthdate column, along with the current date and time.

But, the age that is displayed in the Age column, doesn't look like an age. That is because it is an actual length.

Duration

Duration is a particular type of data that is utilized in Power Query which represents the difference in the two DateTime values. Duration is the combination of four numbers:

days.hours.minutes.seconds

This is the way you interpret the above data. For the perspective of an individual, you do not need them to search for information like this. There are methods that can determine each component that is an amount of time. If you select the Duration menu , you'll be able to see that you'll be able extract the number of seconds, minutes or hours, days, and years from it.

to assist with calculating the age in years such as, say, it is easy to select Total Years.

Note that the length of the program is measured by days and then subdivided into 365, providing you with the annual figure.

Rounding

No one claims they're 53.813698630136983! They use the term 53, then they round it down. It's simple to select Rounding or Round Down on the Transform tab.

This will give you the age in years:

It's also possible to cleanse other columns if you'd like (or maybe you've made use of transformations within the Transform tab to avoid the creating of additional columns) This column can be renamed as Age column and Age:

Things to Know

  • Refresh The age calculated in this way is updated every time you are refreshing your database. Each time, it will match the birthdate with the date and the time of the refresh. This method is an initial calculation of the age. If you're in need of this calculation performed dynamically using DAX here I provided a method you could apply.
  • The motive for Power Query: Benefits of doing calculations on age in Power Query is that the calculation is done when you refresh your report, using an instrument that makes the calculation simpler, and there's no additional cost of doing it with DAX to gauge the time of runtime.
  • Another case where these are not meant to calculate age but rather start at the date of birth. This could be used for the age of inventory of items, as well as the distinction in dates between dates one another.

Video

REZA RAD

TRAINER, CONSULTANT, MENTORReza Rad is a Microsoft Regional Director, an Author, Trainer, Speaker and Consultant. He holds a BSc of Computer engineering. He holds greater than twenty years' working experience in data analysis data and BI, database development, and programming mostly using Microsoft technologies. He has been a Microsoft Data Platform MVP for nine years consecutively (from 2011 to the present) for his commitment towards Microsoft BI. Reza can be found as an active writer and co-founder of RADACAD. Reza is also co-founder and organizer of Difinity Conference which is held 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 some ebooks on MS SQL BI and also is working on a few more. The author was a frequent member on online technical forums such as MicrosoftDN as well as Experts-Exchange and was the moderator of MSDN SQL Server forums, and is an MCP, MCSE, and the MCITP for Business Intelligence. He is the creator of the New Zealand Business Intelligence users group. In addition, he is the creator of the famous book Power BI from Rookie to Rock Star, which is free and has more than 170 pages of content as well as it is a element of Power BI Pro Architecture published by Apress.
It is an International Speaker at Microsoft Ignite, Microsoft Business Applications Summit, Data Insight Summit, PASS Summit, SQL Saturday and SQL User Groups. And He is a Microsoft Certified Trainer.
Reza's passion is to help users find the right solutions for their data, and he's a Data enthusiast.This post was published in Power BI, Power BI from Rookie to Rockstar, Power Query and is filed into Power BI, Power BI from Rookie to Rock Star, Power Query. Bookmark the permalink.

Post navigation

Share visual pages on various security groups inside Power BIAge Calculation in Years which can be used for calculate Leap Year in Power Business Intelligence by using Power Query

Comments

Popular posts from this blog

pace-converter

Random Number Generator

Bound Meaning In Tamil