Age Calculation in Power BI using Power Query

Power Query has a simple method of calculating the age. But, because DAX is the most popular language usedin several calculationin Power BI, many do not know about this function in Power Query. In this blog , I will describe how simple to calculateAge in Power BI with Power BI. This methodis highly beneficial in situations where the calculation of agecan be completed using a previously calculated row-by-row basis.

Calculate Age from a date

Here is the DimCustomer table in the AdventureWorksDW table that has an age column. I've removed a few columns that aren't needed to make it more readable;

To calculate the age of every buyer, you need is:

  • In Power BI Desktop, Click on Transform Data
  • In the PowerQuery Editor window make sure to select the first column in the Birthdate column.
  • Click on the Add Column Tab. Under the "From Date & Time" section, and then under Date Select the appropriate age range.

That's about it. This will calculate the amount which is the total from the Birthdate column along with the current date and time.

However, the age which appears in the Age column does not actually appear to be an age. This is because it's an actual duration.

Duration

Duration is a distinct form of data which is used for Power Query which represents the distinction between the two DateTime values. Duration is the mixture of four different values:

days.hours.minutes.seconds

This is how you see the above statements. From one's own perspective, you don't need them to search for facts like this. There are ways to find each part that represents an amount of time. When you go to the Duration menu , you'll be able to see that you are able to extract the amount of seconds or minutes as well as days, hours and years out of it.

to assist with calculating the age in years like, for example, it is easy to select Total Years.

Note that the length of the program is measured by days and then subdivided into 365 to provide you with an annual amount.

Rounding

No one claims they're 53.813698630136983! They refer to it as 53 and then round it down. It's simple to select rounding as well as Round Down from the Transform tab.

This will give you the number in years:

It's then possible to cleanse other columns if you'd like (or maybe you've made use of transformations using the Transform tab to avoid the creating of additional columns) This column may be changed to an age: column; Age:

Things to Know

  • Refresh The age that is calculated in this manner is updated every time you refresh your database. Each time, it will match the birthdate with the date and date that the database refresh was made. This method is an initial calculation of the age. If you're in need of your calculation run dynamically with DAX, I've provided a method is possible to use.
  • The reasoning for Power Query: Benefits of making age calculations with Power Query is that the calculation is performed at the time of refreshing your report. You use an instrument that makes calculations easier and there's no cost to doing it using DAX to determine the time of runtime.
  • Another scenario These are not in use to calculate age, only beginning at the date of birth. This can be used to calculate the time of inventory on products , and also for the difference between two dates or dates 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 of Computer engineering. He holds over 20 years of working experience in data analysis, BI, databases developing, and programming mostly on Microsoft technologies. He has been a Microsoft Data Platform MVP for nine years consecutively (from 2011 to the present) in recognition of his commitment to Microsoft BI. Reza can be found as an active writer and co-founder of RADACAD. Reza is also co-founder and co-organizer at the 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 books about MS SQL BI and also is working on a few more. The author was a regular member of online technical forums such as MSDN and Experts-Exchange and was the moderator on the MSDN SQL Server forums, and holds the MCP in addition to MCSE, MCP, and MCITP for Business Intelligence. He is the founder of the New Zealand Business Intelligence users group. Additionally, he's the creator of the famous workbook Power BI from Rookie to Rock Star, which is free and has more than 170 pages of information and component 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 love is helping users find the right data solution. He's a Data enthusiast.This post was uploaded within Power BI, Power BI from Rookie to Rockstar, Power Query and is listed in Power BI, Power BI from Rookie to Rock Star, Power Query. The following is apermalink.

Post navigation

Use different visual pages to share with various security groups inside Power BIAge Calculation in Years that can be used to calculate Leap Year in Power BI through Power Query

Comments

Popular posts from this blog

BMI calculator

counting in hindi numbers - (0 to 100)| Hindi Sankhya

Hindi Meaning of PROTECT - PROTECT का हिन्दी अर्थ