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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Jarda
Regular Visitor

how to split number into interval

Hello all,

I would like to create new column an "aging interval". It should be a diff between the column "Posting date" and actual date and divided into the 6 month intervals (0-3M, 4-6M, 7-12M, 13-24M, 25-36M, >36M). Could anyone advise?

 

Thank you ina advance.

 

Jarda

3 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

Sample data would help but I would suggest creating a column using a SWITCH statement and use DATEDIFF something like:

 

Column = SWITCH(DATEDIFF([Date1],[Date2],MONTH),
    0,"0-3M",
    1,"0-3M",
    2,"0-3M",
    3,"0-3M",
    4,"4-6M",
    5,"4-6M",
    6,"4-6M",
...
)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Arentir
Resolver III
Resolver III

Hi Jarda,

 

You could have two calculated columns

DiffMonth = DATEDIFF([Posting Date],[Actual Date], MONTH)

Aging Interval = IF ( Table1[DiffMonth] <= 3,"0-3M",
                                  IF (Table1[DiffMonth] <= 6, "4-6M",
                                       IF(...)
                                     )
                               )

 

View solution in original post

AkhilAshok
Solution Sage
Solution Sage

A calcualted column like this should help:

Aging Interval =
VAR MonthsBetween =
    DATEDIFF ( 'Table'[Start Date], 'Table'[End Date], MONTH )
RETURN
    SWITCH (
        TRUE (),
        MonthsBetween <= 3, "0-3M",
        MonthsBetween <= 6, "4-6M",
        MonthsBetween <= 12, "7-12M",
        MonthsBetween <= 24, "13-24M",
        MonthsBetween <= 36, "25-36M",
        ">36M"
    )

View solution in original post

3 REPLIES 3
AkhilAshok
Solution Sage
Solution Sage

A calcualted column like this should help:

Aging Interval =
VAR MonthsBetween =
    DATEDIFF ( 'Table'[Start Date], 'Table'[End Date], MONTH )
RETURN
    SWITCH (
        TRUE (),
        MonthsBetween <= 3, "0-3M",
        MonthsBetween <= 6, "4-6M",
        MonthsBetween <= 12, "7-12M",
        MonthsBetween <= 24, "13-24M",
        MonthsBetween <= 36, "25-36M",
        ">36M"
    )
Arentir
Resolver III
Resolver III

Hi Jarda,

 

You could have two calculated columns

DiffMonth = DATEDIFF([Posting Date],[Actual Date], MONTH)

Aging Interval = IF ( Table1[DiffMonth] <= 3,"0-3M",
                                  IF (Table1[DiffMonth] <= 6, "4-6M",
                                       IF(...)
                                     )
                               )

 

Greg_Deckler
Super User
Super User

Sample data would help but I would suggest creating a column using a SWITCH statement and use DATEDIFF something like:

 

Column = SWITCH(DATEDIFF([Date1],[Date2],MONTH),
    0,"0-3M",
    1,"0-3M",
    2,"0-3M",
    3,"0-3M",
    4,"4-6M",
    5,"4-6M",
    6,"4-6M",
...
)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.