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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
inglexjc
Post Patron
Post Patron

Code to show case active when there is a future date

I have a report that uses this code to show if a case is active or not:

 

End of Service Date/Open = SWITCH(
IF(
ISBLANK(PBI_TR_Placements_OOH[SERVICE_END_DATE]),0,
PBI_TR_Placements_OOH[SERVICE_END_DATE]),0,"Active",
PBI_TR_Placements_OOH[SERVICE_END_DATE],
FORMAT(PBI_TR_Placements_OOH[SERVICE_END_DATE],"Short Date"))
 
Issue is sometimes there are future dates entered into the Service_end_date and the case is then showing closed.  I need it to show Active when the date is in the future.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @inglexjc ,

Please try to create a new column with below dax formula:

Column =
VAR _a =
    IF ( ISBLANK ( [Date] ), 0, [Date] )
VAR _b =
    SWITCH (
        TRUE (),
        _a = 0, "Active",
        NOT ( ISBLANK ( [Date] ) )
            && [Date] > TODAY (), "Active",
        FORMAT ( [Date], "short date" )
    )
RETURN
    _b

vbinbinyumsft_0-1698218827846.png

Please refer the attached .pbxi 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

6 REPLIES 6
Anonymous
Not applicable

Hi @inglexjc ,

In order to better understand your demands and give the right solution, could you please provide some more specific information? such as your desensitized example data and a screenshot of your desired results?

Thanks for your efforts & time in advance.

 

Best regards,
Community Support Team_Binbin Yu

So my current table with code 

End of Service Date/Open = SWITCH(
IF(
ISBLANK(PBI_TR_Placements_OOH[SERVICE_END_DATE]),0,
PBI_TR_Placements_OOH[SERVICE_END_DATE]),0,"Active",
PBI_TR_Placements_OOH[SERVICE_END_DATE],
FORMAT(PBI_TR_Placements_OOH[SERVICE_END_DATE],"Short Date"))

 

inglexjc_0-1698085041342.png

Comes up with these results.  But I need all the dates that are in the future to show "Active" as well.  So example listed 11/1/2023 and 1/1/2024 need to read "Active".

Anonymous
Not applicable

Hi @inglexjc ,

Please try to create a new column with below dax formula:

 

End of Service Date/Open =
VAR _a =
    IF (
        ISBLANK ( PBI_TR_Placements_OOH[SERVICE_END_DATE] ),
        0,
        PBI_TR_Placements_OOH[SERVICE_END_DATE]
    )
VAR _b =
    SWITCH (
        TRUE (),
        _a = 0, "Active",
        PBI_TR_Placements_OOH[SERVICE_END_DATE] > TODAY (), "Active",
        PBI_TR_Placements_OOH[SERVICE_END_DATE], FORMAT ( PBI_TR_Placements_OOH[SERVICE_END_DATE], "Short Date" )
    )
RETURN
    _b

 

 

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. 

@Anonymous  Thank you for your response.  I do get an error with this though:

 

inglexjc_0-1698155913634.png

 

Anonymous
Not applicable

Hi @inglexjc ,

Please try to create a new column with below dax formula:

Column =
VAR _a =
    IF ( ISBLANK ( [Date] ), 0, [Date] )
VAR _b =
    SWITCH (
        TRUE (),
        _a = 0, "Active",
        NOT ( ISBLANK ( [Date] ) )
            && [Date] > TODAY (), "Active",
        FORMAT ( [Date], "short date" )
    )
RETURN
    _b

vbinbinyumsft_0-1698218827846.png

Please refer the attached .pbxi 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. 

amitchandak
Super User
Super User

@inglexjc , I have created an active/current employee measure using start and end dates, which should help

 

Power BI: HR Analytics - Employees as on Date: https://youtu.be/e6Y-l_JtCq4
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
Power BI HR Active Employee Tenure Bucketing, and Hired, Terminated, and Active employees: https://youtu.be/fvgcx8QLqZU

 

The sample file is attached

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors