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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
MathiasBI
Regular Visitor

Creating calculated columns which show value from four different intervals

Hi!

 

I'm trying to create four columns that shows four different intervals:

Today - 1 month to date

1 month to date - 2 months to date

2 months to date - 3 months to date

3 months to date +++

 

I'm using a column which shows 'Due Date' to determine which column it should belong, and another column 'Amount (LCY)' that needs to be calculated based on the date intervals.

 

I've tried different types of DAX code, but I keep getting a lot of value in no man's land..

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

I ended up creating variables for the past 1, 2 and 3 months, and equally for 1 month minus 1 day, 2 months minus 1 day etc.. like this:
Var 1m-1d = Date(Year(TODAY()), Month(TODAY()) - 1, Day(TODAY()-1))

 

Then I used this formula to calculate the total amount that was due between two dates:

Due 1m-2m = CALCULATE(SUM([Amount]),DATESBETWEEN([Due Date], [2m before today], [1m-1d after today]))

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @MathiasBI ,

Please have a try.

column =
VAR _1 = table[date]
VAR _2 =
    DATEDIFF ( _1, TODAY (), DAY )
RETURN
    IF (
        _2 <= 30
            && _2 >= 0 = 0,
        "Today - 1 month to date",
        IF (
            _2 <= 60
                && _2 > 30,
            "1 month to date - 2 months to date",
            IF (
                _2 <= 90
                    && _2 > 60,
                "2 months to date - 3 months to date",
                "3 months to date +++"
            )
        )
    )
column =
CALCULATE (
    SUM ( table[value] ),
    FILTER ( table, table[column] = EARLIER ( table[column] ) )
)

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Anonymous ,

 

I ended up creating variables for the past 1, 2 and 3 months, and equally for 1 month minus 1 day, 2 months minus 1 day etc.. like this:
Var 1m-1d = Date(Year(TODAY()), Month(TODAY()) - 1, Day(TODAY()-1))

 

Then I used this formula to calculate the total amount that was due between two dates:

Due 1m-2m = CALCULATE(SUM([Amount]),DATESBETWEEN([Due Date], [2m before today], [1m-1d after today]))

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.