Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
nish18_1990
Helper II
Helper II

How Create Graph with Date difference and age bucket

Hi,

 

I have data like below :

 

nish18_1990_0-1743685154855.png

 

Logic for Age is : Created date -Today date 

Bucket is based on age : if it is <30 days then "<30", if <60 and >31 days then "<60 "

 I need to show in graphs like below : 

 

nish18_1990_1-1743685268996.png

 

Please attache Power BI file for reference . 

 

Thanks

 

1 ACCEPTED SOLUTION
v-sgandrathi
Community Support
Community Support

Hi @nish18_1990,

Thank you for using Microsoft Community Forum.

 

Below is the approach to achieving your desired bar chart visualization in Power BI based on your sample data.

Open Power BI Desktop, go to Home > Get Data, choose Excel or CSV, select your file, and click Load to import the data.

To calculate age, create a new column in Power BI using this DAX formula:


Age = DATEDIFF(TODAY(), 'Sheet1'[Created date], DAY)


This will give the number of days between today and the created date.

 

To group records by age range, create a new column using this DAX formula:

 

Bucket =

IF('Sheet1'[Age] < 30, "<30",

    IF('Sheet1'[Age] <= 60, "<60",

        IF('Sheet1'[Age] <= 90, ">30 - 60",

            ">60"

        )

    )

)

 

This will categorize each record into buckets like <30, <60, >30 - 60, and >60 based on the age in days.

 

To create the bar chart, go to the Report View in Power BI and select the Clustered Column Chart from the Visualizations pane. Drag Created date to the X-axis, Sum of Quantity Q2 to the Y-axis, and Bucket to the Legend. Then, format the chart by sorting it by Created Date, adjusting the colors for each bucket, and renaming the chart to "Sum of Quantity Q2 by Created Date and Age Bucket.

 

If this solution worked for you, kindly mark it as Accept as Solution and feel free to give a Kudos, it would be much appreciated!

 

Thank you.

View solution in original post

6 REPLIES 6
v-sgandrathi
Community Support
Community Support

Hi @nish18_1990,

Thank you for using Microsoft Community Forum.

 

Below is the approach to achieving your desired bar chart visualization in Power BI based on your sample data.

Open Power BI Desktop, go to Home > Get Data, choose Excel or CSV, select your file, and click Load to import the data.

To calculate age, create a new column in Power BI using this DAX formula:


Age = DATEDIFF(TODAY(), 'Sheet1'[Created date], DAY)


This will give the number of days between today and the created date.

 

To group records by age range, create a new column using this DAX formula:

 

Bucket =

IF('Sheet1'[Age] < 30, "<30",

    IF('Sheet1'[Age] <= 60, "<60",

        IF('Sheet1'[Age] <= 90, ">30 - 60",

            ">60"

        )

    )

)

 

This will categorize each record into buckets like <30, <60, >30 - 60, and >60 based on the age in days.

 

To create the bar chart, go to the Report View in Power BI and select the Clustered Column Chart from the Visualizations pane. Drag Created date to the X-axis, Sum of Quantity Q2 to the Y-axis, and Bucket to the Legend. Then, format the chart by sorting it by Created Date, adjusting the colors for each bucket, and renaming the chart to "Sum of Quantity Q2 by Created Date and Age Bucket.

 

If this solution worked for you, kindly mark it as Accept as Solution and feel free to give a Kudos, it would be much appreciated!

 

Thank you.

Hi @nish18_1990,

 

We haven’t heard from you on the last response and was just checking back to see if your query was answered.
Otherwise, will respond back with the more details and we will try to help .

If our response has addressed your query, please accept it as a solution and give a ‘Kudos’ so other members can easily find it. Please let us know if there’s anything else we can do to help.

 

Thank you.

nish18_1990
Helper II
Helper II

please find the attached table 

johnt75
Super User
Super User

You can use the techniques described in https://www.daxpatterns.com/static-segmentation/ 

lbendlin
Super User
Super User

Please make an effort to provide sample data in usable format, not as a screenshot.

CategoryQuantity Q2countryCreated date
Tables20China23/05/2025
Cars30China21/01/2025
Bikes40China21/03/2025
Chairs13India21/01/2025
Tables22India21/02/2025
Cars54India21/01/2025
Bikes60India30/01/2025

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.