Age Calculation

Age Calculation in Power BI using Power Query

Power Query has a simple method to calculating the age. However, as DAX is one of the well-known language usedin numerous calculationsin Power BI, many don't know about this feature available in Power Query. In this blog post , I will show how easy you can calculateAge within Power BI using Power BI. This methodis very beneficial when you have for calculate the age calculationscan be done using a calculated row-by-row basis.

Calculate Age from a date

Here's the DimCustomer table, which is an element of the AdventureWorksDW table that is the column for birthdates. I've removed a few columns that aren't necessary to make it easier to read;

To calculate the age of each client is, all you need to do is to:

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

This is all there is to it. This is the method to calculate the ratio between the birthdate column as well in the current date and time.

However, the age that appears in the Age column isn't really believed to be an actual age. It's because it's an actual length.

Duration

Duration is a specific type of data that is utilized to calculate the duration of Power Query which represents the variations between the two DateTime values. Duration is a combination with four values:

days.hours.minutes.seconds

This is how you understand the above numbers. However, from the viewpoint of the user, it's not their responsibility to comprehend the details of this. There are ways to determine each part of the time. When you select the Duration menu, you'll be able to see the number of minutes, seconds, hours, days , and years.

to assist to assist calculating the age in years like, for example, it is simple to choose Total Years.

It is crucial to remember it is that durations are measured as days, and then divided by the number of days, so that you can get the value for the year.

Rounding

In the end, no one declares they are 53.813698630136983! They state 53, which is rounding down. It's easy to choose Rounding, and then the round down option on the Transform tab for it.

This will give you the years of age:

After that, you can clear the other columns, should you want to (or you could find because you used transformations on the Transform tab to avoid creating new columns) The column could be named as Age column Age.

Things to Know

  • Refresh The age that is calculated by this method will be updated every time you refresh your data. Every time, it will be matched the birth date with the date and the date when the refresh occurred. The method can be described as an algorithm used for pre-calculating the age. If, however, you need the calculation of the age to be done dynamically using DAX This article will explain the method that you can apply.
  • What's the reason? Power Query The benefit of using the calculation of age using the Power Query is that the calculation takes place in the course of refreshing your report. The calculation is performed using an application which makes the calculation simpler and also there is no extra cost to calculate it using DAX as a measurement of the runtime.
  • Other scenarios It isn't an alternative method to calculate age solely by birthdate. This is a method to calculate the age of inventory in products as well as the difference between two dates and times that differ 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 has more than 20 years old and has worked in the area of data analysis, programming, BI, databases and development, mainly using Microsoft technologies. He was an official Microsoft Data Platform MVP for nine consecutive years (from 2011 to the present) because of his dedication towards Microsoft BI. Reza has a reputation for being a prolific author and co-founder of RADACAD. Reza is also the co-founder and co-organizer for the 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 couple of publications about MS SQL BI and also is writing other books. He also was a frequent member of technical forums on the internet such as MSDN as well as Experts-Exchange and was the moderator of the MSDN SQL Server Forums and holds the MCP and MCSE , as and the MCITP for Business Intelligence. He is the leader of the New Zealand Business Intelligence users group. In addition, he is the author of the highly popular publication Power BI from Rookie to Rock Star, which is free and has over 17000 pages of data as well as Power BI Pro Architecture, which is 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, as well as SQL User Groups. And He is a Microsoft Certified Trainer.
Reza's aim is to help you find the most efficient data solution. He is an avid Data enthusiast.This blog post was posted with the tags Power BI, Power BI from Rookie to Rockstar, Power Query and was tagged as 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 various visual pages by using various security groups within the Power BIAge's Year Calculation that is used to calculate the Leap Year in Power BI using Power Query

Comments

Popular posts from this blog

angle-converter

illuminance-converter

What is an Influencer?