Age Calculation

Age Calculation in Power BI using Power Query

Power Query has a simple method to calculating the age. However, since DAX is among the used language usedin numerous calculationsin Power BI, many do not realize this function in Power Query. In this blog post , I will explain how simple you can calculateAge in PowerBI using PowerBI. This methodis very helpful in situations where you need for calculate the age calculationscan be done on a row-by row basis.

Calculate Age from a date

Here's the DimCustomer table that's part of the AdventureWorksDW table, which is the birthdate column. I've removed some of the columns that aren't necessary in order to make it more user-friendly;

To calculate the average age of every client must be, all you must do is to:

  • In Power BI Desktop, Click on Transform Data
  • In the PowerQuery Editor window select the first column, Birthdate.
  • Go to the add Column Tab, then under "From Date & Time" section. Then, under Date Select the age range.

That's all there is to it. This is how you calculate the ratio between Birthdate column, as well being the current date and time.

The age displayed in the Age column doesn't actually appear to be an actual age. This is due to its actual duration.

Duration

Duration is one of the types of data used for Power Query which represents the differences in two DateTime values. Duration is a mixture of 4 numbers

days.hours.minutes.seconds

This is the way to look up the values above. However, from the perspective of the user it is not the norm for them to understand the specifics of this. There are ways to determine each part of the time. If you click on the Duration menu you'll be able to see the number of minutes, seconds, hours, and years.

To aid for calculating the age in years for example, it is simple to select Total Years.

It is important to understand how the length is calculated in days and after that divided by number of days to provide you with the annual amount.

Rounding

As a final note, nobody states that you are 53.813698630136983! They simply say 53. This is rounded down. It's easy to select Rounding and then round down option from the Transform tab for it.

This will provide you with the age of the years:

You can then clean the other columns If you'd like (or the reason could be because you made use of transformations within the Transform tab to prevent the creation of new columns) The column could be named as Age: column Age.

Things to Know

  • Refresh The age that is calculated in this way will be updated every time you refresh your data. Every time, it will match the birth date with the date and the moment when the data refresh took place. The method involves an algorithm for pre-calculating age. If, however, you want the calculation of age to be carried out dynamically using DAX Here I have explained the method which you can utilize.
  • Why is this? Power Query Benefits of using age calculation in The benefit of using age calculation with Query is that the calculation is carried out at the time of refresh of your report. It's done with an application that facilitates the calculation as well as there is no extra cost to calculate it using DAX as a measure of runtime.
  • Additional scenarios This is not an method to calculate age just by birthdate. This method can be used to calculate the age of inventory for products and also to determine the differences between dates or 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 of Computer Engineering. He has more that twenty years' experience in the area of data analysis, programming, databases, and BI development primarily using Microsoft technologies. He has been an official Microsoft Data Platform MVP for nine years (from 2011 until today) because of his dedication towards Microsoft BI. Reza is known as a prolific writer and co-founder of RADACAD. Reza is also co-founder and co-organizer of 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 few publications on MS SQL BI and also is working on other books. He was also a regular forum participant on technical forums such as MSDN and Experts-Exchange and was moderator on the MSDN SQL Server forum and holds the MCP and MCSE as well as an MCITP in BI. He is the head for the New Zealand Business Intelligence users group. He is also creator of the highly popular work Power BI from Rookie to Rock Star, which is free and contains more than 17000 pages as well as Power BI Pro Architecture, which is the 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 goal is to help you discover the most effective data solution. He is a Data enthusiast.This article was published in Power BI, Power BI from Rookie to Rockstar, Power Query and was tagged with 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 various security groups within PowerBIAge's Year Calculation that is used for Leap Year in Power BI through Power Query

Comments

Popular posts from this blog

volumeFlowRate-converter

volumeFlowRate-converter