Age Calculation

Age Calculation in Power BI using Power Query

Power Query has a simple method to calculating the age. However, since DAX is the largest and most widely used language usedin numerous calculationsin Power BI, many do not realize this function in Power Query. In this blog post , I will describe how simple for you to calculateAge using Power BI in Power BI. This methodis exceptionally helpful in situations where you need in order to calculate the age calculationscan be carried out by calculating the row-by-row basis.

Calculate Age from a date

Here's the DimCustomer table, which is part of the AdventureWorksDW table which contains the birthdate column. I've removed a few columns that don't need to be there for clarity;

In order to calculate how old every client will be, all you'll need to do is:

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

That's about it. This is the method to calculate what's the ratio between Birthdate column, as well in the current date and time.

However, the date that appears in the Age column doesn't actually appear to be an age. This is due to its actual time period.

Duration

Duration is a specific type of data that is used to calculate the duration of Power Query which represents the variations in two DateTime values. Duration is a combination of 4 numbers

days.hours.minutes.seconds

This is how to read the above values. From the point of view of the user it's not required of them to be able to discern the meaning of these numbers. There are methods that can be used to calculate each fraction of the time. If you click on the Duration menu you'll be able see the quantity of minutes, seconds, hours, months and days from it.

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

It is crucial to remember this: the measurement is in day, and following that, divided by the number of days, to provide you with an annual number.

Rounding

At the final point, nobody says that they are 53.813698630136983! They say 53, which is lower than the original. It's simple to select Rounding, and then the round down option on the Transform tab.

This will provide you with the years of age:

After that, you can clear the other columns, If you'd like (or the reason could be because you utilized transformations in the Transform tab to avoid creating new columns) The column could be named something like Age Column Age.

Things to Know

  • Refresh The age that is calculated in this manner will be updated when refreshing your data. Each time, it's going to match the date of birth to the date and moment when the data refresh took place. That method can be described as an algorithm used for pre-calculating the age. If, however, you need the calculation of the age to be carried out dynamically using DAX Here's how I explained the method which you can employ.
  • What's the cause? Power Query Benefits of using age calculation using The benefit of using age calculation with Query is that the calculation is carried out while you refresh your report. The calculation is performed using an application which makes the calculation simpler, and there is no additional overhead in calculating it using DAX as a measurement of running time.
  • Other scenarios This is not an alternative method to calculate age solely by birthdate. This can be used in order to calculate the stock age for products and also to determine the differences between two dates and 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 than 20 years' worth of experience in the area of data analysis, programming, databases, BI and development mostly using Microsoft technologies. He has been an official Microsoft Data Platform MVP for nine years (from 2011 until now) for his dedication towards Microsoft BI. Reza is a 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 a couple of publications on MS SQL BI and also is working on other books. He was also a regular participant on technical forums online like MSDN and Experts-Exchange and was moderator on the MSDN SQL Server Forums as well as holding the MCP and MCSE as along with the MCITP for BI. He is the leader of the New Zealand Business Intelligence users group. In addition, he's also the writer of the highly well-respected Book Power BI from Rookie to Rock Star, which is free and contains over 17000 pages of data and Power BI Pro Architecture, which is the Power BI Pro Architecture published by Apress.
He 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 purpose is to help you discover the most effective data solution. He is a Data enthusiast.This blog post was posted in 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. The following entry was filed under Power BI.

Post navigation

Share various visual pages by using various security groups within Power BIAge's Year Calculation that is used for Leap Year in Power BI using Power Query

Comments

Popular posts from this blog

10 flowers name In english

Bhagavad Gita in English & bhagavad gita as it is pdf