Age Calculation
Age Calculation in Power BI using Power Query
Power Query has a simple way in calculating the age. But, as DAX is the most popular language usedin several calculationsin Power BI, many don't know about the function that is available in Power Query. In this blog post I will discuss how easy to calculateAge in Power BI using Power BI. This methodis extremely helpful in situations where calculation of the agecan be done using a previously calculated row-by-row basis.
Calculate Age from a date
The table is called the DimCustomer table that is part of the AdventureWorksDW table that has an age column. I've removed columns that weren't needed to make it more readable;
To calculate the exact age each purchaser, the following information is required:
- In Power BI Desktop, Click on Transform Data
- In the Power Query Editor window, select the Birthdate column first
- Click on the Add Column Tab. Under the "From Date & Time" section, and under Date, choose the age range.
It's that simple. it. this calculates the calculate the amount which is the sum from the Birthdate column, along with the current date and time.
However, the date that appears in the Age column, doesn't seem to be an actual age. That is because it is an actual time period.
Duration
Duration is a particular type of data used to calculate the duration of a query in Power Query which represents the variation between the two DateTime values. Duration is the mixture of four numbers:
days.hours.minutes.seconds
This is how you read the above statements. But from one's own perspective, you don't want them to look up information like this. There are ways to make each of the portions that are an amount of time. When you click on the Duration menu , you'll find that you can get the amount of seconds , minutes or hours, days, and years out of it.
In order to aid you in calculating the age in years such as, say, it is simple to choose Total Years.
Make note of the fact that the duration that the programme runs is measured by days and then subdivided into 365 in order to provide you with the annual value.
Rounding
And lastly, nobody claims they're 53.813698630136983! They call it 53, and then then round it down. It's simple to select the Rounding option and Round Down under the Transform tab.
This will provide you with the age in years:
It's then possible to tidy other columns as you'd like (or perhaps you've used the power of transforms on the Transform tab to avoid the formation of new columns) This column can be renamed as 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 with the date and the date for the refreshing. This method is an earlier calculation of the age. If you're looking for your calculation run dynamically using DAX here I gave you a procedure you could use.
- The reasoning behind Power Query: Benefits of doing age calculations using Power Query is that the calculation is performed when you refresh your report. You use an application that makes the calculation much easier, and it's not a expense of using DAX to calculate the time of runtime.
- Another possibility is that they aren't in use to calculate age, only beginning from the birth date. This can be used to calculate the time of inventory on items, as well as the distinction of two date 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 a BSc in Computer engineering. He has greater than twenty years of experience in the fields of data analysis data in BI, databases and programming primarily using Microsoft technologies. He was a Microsoft Data Platform MVP for nine years in a row (from 2011, until now) due to his dedication in the field of Microsoft BI. Reza is an active writer and co-founder of RADACAD. Reza is also co-founder and coordinator 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 also written a few book concerning MS SQL BI and also is writing a few others. Also, he has been a frequent participant in online forums for technical issues such as MSDN , and Experts-Exchange and was the moderator of MSDN SQL Server forums, and holds the MCP as well as MCSE and MCITP for Business Intelligence. He is the creator of the New Zealand Business Intelligence users group. Additionally, he's the author of the well-known publication Power BI from Rookie to Rock Star, which is completely free and includes more than 170 pages of information and element 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 passion is to help users find the right information solution. He is Data enthusiast.This article was published in Power BI, Power BI from Rookie to Rockstar, Power Query and is classified into 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 in Years Calculation which can be used as a way to calculate Leap Year in Power BI through Power Query
Comments
Post a Comment