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
matts29
Frequent Visitor

if date possible switch

Hi 

 

If someone can assist please?

 

I would like to say in 1 column the below please?

The rdate contains a series of dates in the past and the future.

 

rdate = last order over 2 and a half years ago then 1

rdate=  should be re-ordered within 6 months then 2

rdate= order last reviewed less than 2 and a half years ago then 3

 
Thank you
1 ACCEPTED SOLUTION

Ok. I wrote the formula for a measure actually. 

Please use the following for calculated column:

rdateCalc =
VAR __Difference =
    DATEDIFF ( 'SomeDateTable'[rdate], TODAY (), DAY )
VAR __Result =
    IF (
        __Difference > 913,
        1,
        IF (
            __Difference < 913
                && __Difference > 0,
            3,
            IF ( __Difference < 0 && __Difference > -180, 2, BLANK () )
        )
    )
RETURN
    __Result

 

View solution in original post

8 REPLIES 8
matts29
Frequent Visitor

In a calculated column?

Ok. I wrote the formula for a measure actually. 

Please use the following for calculated column:

rdateCalc =
VAR __Difference =
    DATEDIFF ( 'SomeDateTable'[rdate], TODAY (), DAY )
VAR __Result =
    IF (
        __Difference > 913,
        1,
        IF (
            __Difference < 913
                && __Difference > 0,
            3,
            IF ( __Difference < 0 && __Difference > -180, 2, BLANK () )
        )
    )
RETURN
    __Result

 

Ahh that is fantastic-thank you! I need to learn now what everything is doing 🙂

govindarajan_d
Super User
Super User

Hi @matts29 ,

Can you try this?

rdateCalc =
VAR __Difference =
    DATEDIFF ( MAXX ( 'SomeDateTable', 'SomeDateTable'[rdate] ), TODAY (), DAY )
VAR __Result =
    IF (
        __Difference > 913,
        1,
        IF (
            __Difference < 913
                && __Difference > 0,
            3,
            IF ( __Difference < 0 && __Difference > -180, 2, BLANK () )
        )
    )
RETURN
    __Result

 

govindarajan_d_0-1707405446078.png

 

Thanks but I just have all blanks in the column unfortunatley...

Hi @matts29,

 

Can you show the formula and some sample data?

sure this is the adjusted formula

VAR __Difference =
    DATEDIFF ( MAXX ( 'SomeDateTable', 'SomeDateTable'[rdate] ), TODAY (), DAY )
VAR __Result =
    IF (
        __Difference > 913,
        1,
        IF (
            __Difference < 913
                && __Difference > 0,
            3,
            IF ( __Difference < 0 && __Difference > -180, 2, BLANK () )
        )
    )
RETURN
    __Result

 

This s the sample data from the date table 

matts29_0-1707408398632.png

 

 

Hi @matts29 ,

Are you using the formula in Calculated column or measure?

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.