Age Calculation

Age Calculation in Power BI using Power Query

Power Query has a simple method of calculating the age. However, since DAX is by far the most widely used language usedin several functionsin Power BI, a lot of users don't recognize the feature available in Power Query. In this article I will discuss how simple it is to calculateAge within Power BI in conjunction with PowerBI. This methodis extremely helpful for situations when the computation of an agecan be done on a pre-calculated row-by-row basis.

Calculate Age from a date

Here's the DimCustomer table that's one of AdventureWorksDW table which includes an old column. I've eliminated a few additional columns to make it simpler to comprehend.

To calculate an age range for every client, you need is:

  • In Power BI Desktop, Click on Transform Data
  • On the Power Query Editor window; start by selecting the Birthdate column.
  • Click on the Add Column Tab, which is under the "From Date & Time" section. Under Date select the age range.

This is all there is to it. This can calculate an amount that's the product of the column for birthdate, Birthdate column and the current date as well as time.

However, the appearance of the age in this Age column, does not seem to look like an actual age. It is due to the fact that it is a time period.

Duration

Duration is a particular kind of data format that is found in Power Query which represents the distinction between two DateTime values. Duration is a mix with four values:

days.hours.minutes.seconds

This is what you will see in the above values. From a personal viewpoint, they shouldn't have to research specifics that are similar to the ones above. There are ways to be used to determine every minute of the time. With the Duration menu choice, you'll see the number of seconds, minutes, hours, and years out of it.

To calculating the age in years like, for instance it is as simple as going to Total Years.

The duration is measured in days and then divided by 365 to calculate an annual number.

Rounding

No one has claimed that they're 53.813698630136983! they claim 53 with the rounding down. You can simply select the Rounding option . You can then round down the Transform tab.

This will show you what your age is in terms of years

It's also possible to tidy other columns, in the event that you want to (or you could have applied transformations within the Transform tab to avoid creating new columns.) The column could be named column: Age.

Things to Know

  • Refresh The age determined by the method can be refreshed every time you are refreshing your dataset. Each time, it'll compare your birthdate with the date and timing at the time of refresh. This method is an algorithm for pre-calculating your age. If you, however, want the age calculation to be performed dynamically, with DAX, this is how I have described a technique you can use.
  • Benefits of using Power Query: Benefits of calculating age in Power Query is that the calculation is done when you refresh your report. This is done by making use of a tool to make the calculations easier, and there's no need to add the cost of doing it using DAX as a measure of the runtime.
  • Another possibility is that it cannot be used to calculate the age by birthdate. It could be used to determine inventory of products as or the difference in two dates and dates from one another.

Video

REZA RAD

TRAINER, CONSULTANT, MENTORReza Rad is a Microsoft Regional Director, an Author, Trainer, Speaker and Consultant. He holds a BSc in Computer engineering. Over 20 years' experience in data analysis database programming, BI, development and programming primarily focused specifically on Microsoft technologies. He is an official Microsoft Data Platform MVP for nine years (from 2011 to the present) due to his devotion in Microsoft BI. Reza can be described as a prolific writer and co-founder of RADACAD. Reza is also co-founder as well as co-organizer for the Difinity Conference at New Zealand.
His articles on different aspects of technologies, especially on MS BI, can be found on his blog: https://radacad.com/blog.
He wrote a couple of books about MS SQL BI and also is writing a few more. He was also a regular member of online forums for technical issues like MSDN and Experts-Exchange as well as moderator of MSDN SQL Server forums, and is an MCP , the MCSE, as well as the MCITP for BI. Director of the New Zealand Business Intelligence users group. He is also the author of the very well-known workbook Power BI from Rookie to Rock Star, which is available for free and has more that 17000 pages of data and another book titled Power BI Pro Architecture published by Apress.
It is an International Speaker in Microsoft Ignite, Microsoft Business Applications Summit, Data Insight Summit, PASS Summit, SQL Saturday, along with SQL User Groups. And He is a Microsoft Certified Trainer.
Reza's goal is to help you find the most efficient solutions for data, and is an avid Data enthusiast.This article was published in Power BI, Power BI from Rookie to Rockstar, Power Query and related to Power BI, Power BI from Rookie to Rock Star, Power Query. The following article is a good reference to bookmark.

Post navigation

- Share different visual pages using different security groups in Power BIAge's Year Calculation that works for Leap Year in Power BI using Power Query

Comments

Popular posts from this blog

LENGTH CONVERTER

roadies-audition-form-pdf

convert-to-jpeg