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 September 15. Request your voucher.

Reply
Shanil_K
New Member

Check if month in a date column is greater than or less than another month

I have a table with two columns, Allocation Date and POD Date. I would like to check for all orders were the month of the Allocation Date is before the month of the POD date(if the POD date exists). If the POD date exists and the value is true then I want to return the text "Brought forward" else "Not Brought forward".  If the POD date does not exist, I want a 2nd check to check if the month of the Allocation Date is before the current month(based on current date). If true then i want to return the text "Brought forward" else "Not brought forward"

 

Please help me with a formula for this?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Shanil_K ,

Please add two column for the month, don't use Date hierarchy's month.

Create a new measure with below dax formula:

 

Measure3 =
VAR cur_month =
    MONTH ( TODAY () )
VAR cur_all_date_month =
    SELECTEDVALUE ( 'Table'[Allocation Month] )
VAR cur_poddate_month =
    SELECTEDVALUE ( 'Table'[POD Month] )
RETURN
    SWITCH (
        ISBLANK ( cur_poddate_month ),
        TRUE (), IF ( cur_all_date_month < cur_month, "Brought forward", "Not brought forward" ),
        FALSE (),
            IF (
                cur_all_date_month < cur_poddate_month,
                "Brought forward",
                "Not brought forward"
            )
    )

 

vbinbinyumsft_0-1666663683938.pngPlease refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Shanil_K ,

Please try below steps:

1. below is my test table

vbinbinyumsft_0-1666162454269.png

2. create a measure with below dax formula

Measure =
VAR cur_month =
    MONTH ( TODAY () )
VAR cur_all_date_month =
    MONTH ( SELECTEDVALUE ( 'Table'[Allocation Date] ) )
VAR cur_poddate_month =
    MONTH ( SELECTEDVALUE ( 'Table'[POD Date] ) )
RETURN
    SWITCH (
        ISBLANK ( cur_poddate_month ),
        TRUE (), IF ( cur_all_date_month < cur_month, "Brought forward", "Not brought forward" ),
        FALSE (),
            IF (
                cur_all_date_month < cur_poddate_month,
                "Brought forward",
                "Not brought forward"
            )
    )

3. add a table visual with measure and column

vbinbinyumsft_1-1666162607829.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi v-binbinyu-msft

 

Many thanks for the response! I have included the code in my dashboard however if I want to visualise the data on month level only "Brought Forward" text comes through in the table.
The first column below is Allocation month(using Date hierarchy) and 2nd column if POD month(using date hierarchy). Row 3 of the table the BF Status should read "Not Brought forward" however it reads "Brought Forward".
 
Is there something else I am missing?
 
Shanil_K_0-1666184670291.png

Regards

Shanil

 
 
Anonymous
Not applicable

Hi @Shanil_K ,

Please add two column for the month, don't use Date hierarchy's month.

Create a new measure with below dax formula:

 

Measure3 =
VAR cur_month =
    MONTH ( TODAY () )
VAR cur_all_date_month =
    SELECTEDVALUE ( 'Table'[Allocation Month] )
VAR cur_poddate_month =
    SELECTEDVALUE ( 'Table'[POD Month] )
RETURN
    SWITCH (
        ISBLANK ( cur_poddate_month ),
        TRUE (), IF ( cur_all_date_month < cur_month, "Brought forward", "Not brought forward" ),
        FALSE (),
            IF (
                cur_all_date_month < cur_poddate_month,
                "Brought forward",
                "Not brought forward"
            )
    )

 

vbinbinyumsft_0-1666663683938.pngPlease refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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