cancel
Showing results for
Did you mean:

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Helper V

If date is in previous month flag

Hello folks,

I am trying to create a column to create a flag (FlagColumn) which is to have the below logic.

If any of the Date1 or Date2 happened in the previous month, then Previous.

If no Dates then NoFlag

I tried using between start of month and EOmonth etc, but doesnt work.

 PersonId Date1 Date2 FlagColumn A123 11/1/23 CurrentMonth A234 NoFlag A456 1/1/23 3/3/23 Earlier A567 6/1/23 6/2/23 Earlier A678 8/1/23 10/1/23 Previous A789 10/2/23 10/4/23 Previous
1 ACCEPTED SOLUTION
Super User

Hi @PBI5851 ,
You can use the below DAX in a new measure:

`Flag =SWITCH(    TRUE(),    MAX('Table'[Date1]) = BLANK() && MAX('Table'[Date2]) = BLANK(), "No Flag",    MONTH(MAX('Table'[Date1])) = MONTH(TODAY()) || MONTH(MAX('Table'[Date2])) = MONTH(TODAY()), "Current Month",    MONTH(MAX('Table'[Date1])) = MONTH(TODAY()) - 1 || MONTH(MAX('Table'[Date2])) = MONTH(TODAY()) - 1, "Previous Month",    "Earlier")`

Result:

 Give a Thumbs Up if this post helped you in any way and Mark This Post as Solution if it solved your query !!!Proud To Be a Super User !!!LinkedIn
Super User

Hi @PBI5851 ,
You can use the below DAX in a new measure:

`Flag =SWITCH(    TRUE(),    MAX('Table'[Date1]) = BLANK() && MAX('Table'[Date2]) = BLANK(), "No Flag",    MONTH(MAX('Table'[Date1])) = MONTH(TODAY()) || MONTH(MAX('Table'[Date2])) = MONTH(TODAY()), "Current Month",    MONTH(MAX('Table'[Date1])) = MONTH(TODAY()) - 1 || MONTH(MAX('Table'[Date2])) = MONTH(TODAY()) - 1, "Previous Month",    "Earlier")`

Result:

 Give a Thumbs Up if this post helped you in any way and Mark This Post as Solution if it solved your query !!!Proud To Be a Super User !!!LinkedIn

Announcements

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors