Age Calculation

Age Calculation in Power BI using Power Query

Power Query has a simple method for calculating the age. However, since DAX is the primary language usedin numerous calculationsin Power BI, many are not aware of this feature in Power Query. In this article I'll explain how simple it is to calculateAge within Power BI using PowerBI. This methodis extremely useful when your estimation of your agecan be calculated using an earlier calculated row-by-row row basis.

Calculate Age from a date

Below you'll find the DimCustomer table, which is an integral part of the AdventureWorksDW table, which is an entry point for the birthday column. I've removed a few of additional columns making it simpler to read.

To calculate your age for each client All you have to do is:

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

That's that. this is the method you calculate an amount which is the total of the column for Birthdate column, and the current date and time.

But, the age that appears in"under" the Age column, but doesn't appear to be a real age. It's due to the fact that it's an actual time period.

Duration

Duration is a distinct data type in Power Query which represents the difference between two DateTime values. Duration is a combination of four numbers:

days.hours.minutes.seconds

and that is how you consider the above data. For the view of the user, it's not their responsibility to read the specifics of this. There are techniques that can extract every bit of information from the period. By choosing the duration menu you'll find that it is possible to extract the number of seconds and minutes as well as days, hours and years from it.

To assist with calculating the age in years like, for instance you can hit Total Year:

Take note that the duration of the time is calculated in days . Then, it's divide by the total number of days, to calculate the annual amount.

Rounding

No one declares they are 53.813698630136983! They use the word 53 which is an arbitrary number that is rounded down. It is easy to select Rounding and Round Down from the Transform tab.

This will give you an indication of the age you've reached in your years.

Then, you can clean the other columns, should you like (or perhaps you've made use of transformations with the Transform tab, avoiding having you create new columns) And name this column Age:

Things to Know

  • Refresh The age that is calculated this way will get changed each time you're refreshing your data. Each time, it compares the date of birth to the date and timing at the time of refresh. This method is an algorithm for pre-calculating an age. If you want the calculation to be done dynamically with DAX this is the way I explained the method you could apply.
  • The reason behind Power Query: Benefits of performing an age calculation using Power Query is that the calculation is done at the time of refresh of your report. It is an instrument which makes the calculation faster and more efficient, and there's no added cost when it is calculated using DAX to measure runtime.
  • Alternative scenarios It's not utilized to calculate the date of birth. this can be used for the age of inventory at the stock level and the differences between two dates or times from each other.

Video

REZA RAD

TRAINER, CONSULTANT, MENTORReza Rad is a Microsoft Regional Director, an Author, Trainer, Speaker and Consultant. He holds the BSc on Computer engineering; he is more than twenty years' experience in the field of data analysis and databases, BI, and development mostly in Microsoft technologies. He has been a Microsoft Data Platform MVP for 9 consecutive years (from 2011 to the present) in recognition of his passion with Microsoft BI. Reza is an experienced blog writer and co-founder and the editor for RADACAD. Reza is also co-founder and co-organizer for Difinity Conference. 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 books on MS SQL BI and also is working on more books. He was also a frequent forum participant on online forums for technical matters like MSDN and Experts-Exchange and was also the moderator of MSDN SQL Server forums, and is an MCP and MCSE and an MCITP of Business Intelligence. He is also the leader of the New Zealand Business Intelligence users group. In addition, he is the co-author of the well-known guidebook Power BI from Rookie to Rock Star, which is free and contains more than 1800 pages of material and Power BI Pro Architecture, which is the Power BI Pro Architecture published by Apress.
This speaker has been an International speaker at Microsoft Ignite, Microsoft Business Applications Summit, Data Insight Summit, PASS Summit, SQL Saturday and SQL Users Groups. And He is a Microsoft Certified Trainer.
Reza's love is helping users find the right data solution. He is an avid Data enthusiast.This article was published by Reza in Power BI, Power BI from Rookie to Rockstar, Power Query and is filed with Power BI, Power BI from Rookie to Rock Star, Power Query. This entry was posted in Power BI. You can follow any responses to this entry through the RSS feed.

Post navigation

- Share different visual pages using different security groups in Power BIAge's Years Calculation that can be used for Leap Year in Power BI by using Power Query

Comments

Popular posts from this blog

KGF Full Form The complete form of the KGF?

energy-converter

BMI Calculator