Age Calculation

Age Calculation in Power BI using Power Query

Power Query has a simple method to calculating the age. However, as DAX is the most used language usedin numerous computationsin Power BI, many do not know about this feature available in Power Query. In this blog post I will show how easy you can calculateAge in Power BI using Power BI. The methodis exceptionally beneficial in situations where you need for calculate the calculations of agecan be made on a row-by row basis.

Calculate Age from a date

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

In order to calculate the average age of every client has reached, the only thing you'll need to do is:

  • 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 next to the "From Date & Time" section, and under Date, choose the age range.

This is all there is to it. This is the method to calculate what is the ratio between Birthdate column, as well with the current date and time.

However, the age shown on the Age column does not appear to be an actual age. This is due to its actual time period.

Duration

Duration is a distinct type of data utilized to calculate the duration of Power Query which represents the differentiating factors between Two DateTime values. Duration is made up with four values:

days.hours.minutes.seconds

This is the way to get the above data. But from the standpoint of the user, it's not the norm for them to understand the specifics of this. There are techniques to find each segment of time. By selecting the Duration menu you'll see the amount of seconds, minutes, hours and years.

To assist with calculating the age in years such as, for instance it is simple to select Total Years.

It is essential to know that the duration is measured in days and after that divided by the number of days in order to calculate the value for the year.

Rounding

Final note: nobody states that the age of their child is 53.813698630136983! They state 53, which is reduced to. It's easy to choose Rounding and then choose the round down option from the Transform tab.

This will tell you the year of birth:

Then, you can tidy the other columns, as you'd like (or the reason could be because you applied transformations to the Transform tab to avoid creating new columns) The column could be named Age Column Age.

Things to Know

  • Refresh The age that is calculated in this way will be updated whenever you refresh your data. Each time, it will align the date of birth with the date and time that the data refresh occurred. That method can be described as an algorithm used for pre-calculating age. If, however, you need the calculation of age to be performed dynamically by DAX Here's a description of the method which you can make use of.
  • Why is this? Power Query Advantages of using age calculation using power Query is that the calculation happens during the refresh of your report. It's performed with an application which makes the calculation simpler to do, and there's no additional overhead in calculating it using DAX as a measurement of running time.
  • Additional scenarios This isn't an effective method to calculate age only by birthdate. This can be used to calculate the age of inventory of products and also the differences between dates and times that are different from one.

Video

REZA RAD

TRAINER, CONSULTANT, MENTORReza Rad is a Microsoft Regional Director, an Author, Trainer, Speaker and Consultant. He holds an BSc of Computer engineering. He has more that twenty years' experience in the area of data analysis, programming, BI, databases and development that is mainly based on Microsoft technologies. He was an official Microsoft Data Platform MVP for nine consecutive years (from 2011 until today) due to his dedication towards Microsoft BI. Reza can be described as an prolific author and co-founder of RADACAD. Reza is also co-organizer and co-founder 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 several works regarding MS SQL BI and also is writing other books. He was also a regular user of forums for technical issues such as MSDN as well as Experts-Exchange and was the moderator for the MSDN SQL Server forums as well as holding the MCP and the MCSE as in addition to the MCITP for BI. He is also the head of the New Zealand Business Intelligence users group. In addition, he's also the writer of the highly acclaimed work Power BI from Rookie to Rock Star, which is free and contains an additional 17000+ pages of data 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, as well as SQL User Groups. And He is a Microsoft Certified Trainer.
Reza's aim is to help you to find the most effective data solution. He is an avid Data enthusiast.This post was published on 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. The following entry was filed under Power BI.

Post navigation

Share various visual pages by using different security groups in Power BIAge's Year Calculation that is used to calculate the Leap Year in Power BI by using Power Query

Comments

Popular posts from this blog

What is One Thousand?

counting in hindi

reactiveEnergy-converter