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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
osvaldocordeiro
Regular Visitor

DAX formula that parses whether a date is in the current month, before the month, or after the curre

Good morning guys, I need help in the following sense:

 

If the date is in the current month, it will show a yellow light, if the date is before the month of the current month, it will show a red light and if the date is after the current month, it will show an orange light.

 

I thank you all!

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

@osvaldocordeiro , no problem. Do you know you can edit your post? Click on the three vertical dots at the top-right of the post and select Edit Reply

EylesIT_0-1680270024177.png

 

 

View solution in original post

Good morning Ajendra,

In addition to your help, we managed to solve the challenge. Thanks a lot for the help.

See how it turned out:

Indicator = VAR DATA_X = DATE(YEAR(TODAY()), MONTH(TODAY()), "01") RETURN IF('Portfolio Planning 2023'[Planned Start Period  ].[MonthNo] == MONTH(TODAY()) && YEAR(TODAY()) == 'Portfolio Planning 2023'[Planned Start Period  ].[Year], 0, IF('Portfolio Planning 2023'[Planned Start Period  ]< DATA_X, -1,1))

View solution in original post

8 REPLIES 8
osvaldocordeiro
Regular Visitor

Good morning EylesIT,

In addition to your help, we managed to solve the challenge. Thanks a lot for the help.

See how it turned out:

Indicator = VAR DATA_X = DATE(YEAR(TODAY()), MONTH(TODAY()), "01") RETURN IF('Portfolio Planning 2023'[Planned Start Period  ].[MonthNo] == MONTH(TODAY()) && YEAR(TODAY()) == 'Portfolio Planning 2023'[Planned Start Period  ].[Year], 0, IF('Portfolio Planning 2023'[Planned Start Period  ]< DATA_X, -1,1))

Ajendra
Resolver I
Resolver I

C.JPG

 

Status =
    SWITCH(
        TRUE(),
            MAX(FactTable[Date]) >= EOMONTH(TODAY(),-1)+1 &&
                MAX(FactTable[Date]) <=EOMONTH(TODAY(),0), "Yellow",
                MAX(FactTable[Date])<EOMONTH(TODAY(),-1)+1,"#FFCCCB",
                MAX(FactTable[Date])>EOMONTH(TODAY(),-1)+1,"#FFD580")
 
Try this once!
Use this measure in Conditional formatting >> Find value option

Good morning Ajendra, first I want to thank you for your help. Thank you very much!

I am in need of a calculated column, as the measure did not work in my table. Then, I changed from measure to calculated column, but the result is not working. Look:Screen1.png

 

Thank you in advance if you can help me complete this challenge!

 

Good morning Ajendra,

In addition to your help, we managed to solve the challenge. Thanks a lot for the help.

See how it turned out:

Indicator = VAR DATA_X = DATE(YEAR(TODAY()), MONTH(TODAY()), "01") RETURN IF('Portfolio Planning 2023'[Planned Start Period  ].[MonthNo] == MONTH(TODAY()) && YEAR(TODAY()) == 'Portfolio Planning 2023'[Planned Start Period  ].[Year], 0, IF('Portfolio Planning 2023'[Planned Start Period  ]< DATA_X, -1,1))

Anonymous
Not applicable

@osvaldocordeiro , this is one way. Create a DAX measure 

 

KPIColour = 
    SWITCH(TRUE()
        ,DATEDIFF(SELECTEDVALUE('Period'[date_from]), NOW(), MONTH) = 0, "Current month - Yellow"
        ,DATEDIFF(SELECTEDVALUE('Period'[date_from]), NOW(), MONTH) >= 0, "Before current month - Red"
        ,DATEDIFF(SELECTEDVALUE('Period'[date_from]), NOW(), MONTH) <= 0, "After current month - Orange"
    )

 

This uses teh date field [date_from] in my time table called 'period'. When I create a visual and place the fields [date_from] and the measure KPIColour, this is the result:

EylesIT_1-1680187964126.png

 

 

Hope this helps.

 

Good morning EylesIT, first I want to thank you for your help. Thank you very much!

I am in need of a calculated column, as the measure did not work in my table. Then, I changed from measure to calculated column, but the result is not working. Look:Screen1.png

 

Thank you in advance if you can help me complete this challenge!

Sorry, EylesIT for not putting your name on it.

Anonymous
Not applicable

@osvaldocordeiro , no problem. Do you know you can edit your post? Click on the three vertical dots at the top-right of the post and select Edit Reply

EylesIT_0-1680270024177.png

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.