Age Calculation

Age Calculation in Power BI using Power Query

Power Query has a simple method of calculating the age. However, since DAX is the most popular language usedin several calculationsin Power BI a lot of people don't know about this feature in Power Query. In this blog post , I will show you how simple it is to calculateAge in Power BI with Power BI. This methodis extremely useful when the calculation of the agecan be done using a previously calculated row-by-row basis.

Calculate Age from a date

It's the DimCustomer table that is part of the AdventureWorksDW table, which has the birthdate column. I've removed a few columns that don't need to be there to make it easier to read;

To calculate how old each buyer, you must have:

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

It's that simple. it. This will calculate the amount which is the total of both the Birthdate column, and also the current date and time.

The age that appears in the Age column does not actually appear to be an age. This is because it's an actual time period.

Duration

Duration is a unique type of data used to calculate the duration of a query in Power Query which represents the differences between the two DateTime values. Duration is the sum of four numbers:

days.hours.minutes.seconds

This is the way you interpret the above information. But, from the perspective of an individual, you do not need them to search for details like this. There are ways to find each part that represents in the time period. If you choose the Duration option, you'll see that you can get the number of seconds, minutes or hours, days, and years from it.

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

Note that the length of this program measured in days , and then divided into 365 days to provide you with an annual amount.

Rounding

In the end, nobody says they're 53.813698630136983! They call it 53 and then round it down. It's easy to choose rounding as well as Round Down on the Transform tab.

This will provide you with the age in years:

It's then possible to remove other columns if you'd like (or maybe you've made use of transformations in the Transform tab to stop the creating of additional columns) The column could be named as an Age: column or Age: column.

Things to Know

  • Refresh The age that is calculated by this method will be updated each time you refresh your database. Each time, it will match the birthdate to the date and the date that the database refresh was made. This method is an initial calculation of the age. If you want calculations to be performed dynamically by DAX, I have provided a method you could use.
  • The motivation for Power Query: Benefits of doing age calculations using Power Query is that the calculation is performed when you refresh your report. It's done using an application that makes the calculation simpler, and there's no additional cost to doing it using DAX to determine the time of runtime.
  • Another possibility is that they aren't to be used for age calculations, but only start with the date of birth. This can be used to calculate the inventory age for products , and also for the difference in dates between 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 in Computer engineering. He has over 20 years of expertise in the field of data analysis data databases, BI and programming primarily using Microsoft technologies. He was an Microsoft Data Platform MVP for nine years in a row (from 2011 to the present) because of his dedication towards Microsoft BI. Reza has been an active writer and co-founder of RADACAD. Reza is co-founder and organizer of 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 a couple of publications about MS SQL BI and also is working on a few more. In addition, he was a frequent participant on technical forums online like MicrosoftDN as well as Experts-Exchange and was also the moderator of MSDN SQL Server forums, and holds the MCP and MCSE as well as the MCITP for Business Intelligence. He is the creator of the New Zealand Business Intelligence users group. The group is the author of the popular publication Power BI from Rookie to Rock Star, which is free and contains more than 170 pages of information and is a 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 goal is to help users find the most effective data solution. He is a Data enthusiast.This post was published in Power BI, Power BI from Rookie to Rockstar, Power Query and is classified in Power BI, Power BI from Rookie to Rock Star, Power Query. This entry was posted in Power BI. Bookmark the permalink.

Post navigation

Share various visual pages by different security groups in Power BIAge Calculation in Years which can be used in order to calculate Leap Year in Power BI using Power Query

Comments

Popular posts from this blog

10 flowers name In english

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

Conor McGregor Family