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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
RichOB
Post Partisan
Post Partisan

Assigning values in a new column based on dates

Hi, I need a new column that assigns an entry per property based on dates.

 

In this scenario, I have 2 properties that need gas checks conducted every year per each property. When we reach the expiry date for a property, a new gas check is performed, and a certification is issued for another year. I need a new column to determine if the checks are being completed on time. The calculation for the new status column is based on the expiry date and the issue date of the next check (per property). Using the table below, I need the column status to be:

 

- If the issued date of the new check (per property) is the same as the previous expiry date = Completed On Target

- If the issue date is before the previous expiry date = Completed On Target

- If the issue date is later than the previous expiry date = Completed Outside of Target

 

The first entry per property is blank as they have no previous expiry dates.

 

PropertyStat_IDIssue_DateExpiry_DateStatus (this is the column I need)
1 Lakeshore DriveG101/04/202201/04/2023 
1 Lakeshore DriveG201/04/202301/04/2024Completed On Target
1 Lakeshore DriveG307/06/202407/06/2025Completed Not On Target
1 Lakeshore DriveG417/06/202517/06/2026Completed Not On Target
22 Giddings StG526/07/202226/07/2023 
22 Giddings StG629/07/202329/07/2024Completed Not On Target
22 Giddings StG706/08/202406/08/2025Completed Not On Target
22 Giddings StG806/08/202506/08/2026Completed On Target
3 REPLIES 3
v-dineshya
Community Support
Community Support

Hi @RichOB ,

Thank you for reaching out to the Microsoft Community Forum.

 

Hi @Poojara_D12  and @GrowthNatives , Thank you for your prompt responses.

 

Hi @RichOB ,

You need the column status to be satisfy the below 3 conditions.

 

1. If the issued date of the new check (per property) is the same as the previous expiry date = Completed On Target

2. If the issue date is before the previous expiry date = Completed On Target

3. If the issue date is later than the previous expiry date = Completed Outside of Target

 

Please refer below output snap and attached PBIX file.

 

vdineshya_0-1757934772789.png

 

I hope this information helps. Please do let us know if you have any further queries.

 

Regards,

Dinesh

Poojara_D12
Super User
Super User

Hi @RichOB 

What you need is a calculated column that looks at each property’s certification records in sequence, compares the current record’s Issue_Date against the Expiry_Date of the previous record for that same property, and then assigns a status. The logic is straightforward: for the very first record per property, you cannot compare against a prior expiry date, so the status remains blank. For subsequent rows, if the Issue_Date is on or before the previous Expiry_Date, you mark it as Completed On Target, and if the Issue_Date is after the previous Expiry_Date, you mark it as Completed Outside of Target. In DAX, this typically involves using functions like EARLIER/EARLIEST or VAR with CALCULATE(MAX(Expiry_Date)) filtered to rows for the same property with an earlier Issue_Date. By comparing the current row’s Issue_Date to that calculated previous expiry, the column can return the correct status per row. This way, your data will clearly show whether each property’s gas check was completed on time or delayed.

Status =
VAR CurrentProperty = [Property]
VAR CurrentIssue = [Issue_Date]
VAR CurrentID = [Stat_ID]
VAR PrevExpiry =
    CALCULATE (
        MAX ( Table1[Expiry_Date] ),
        FILTER (
            Table1,
            Table1[Property] = CurrentProperty
                && (
                    Table1[Issue_Date] < CurrentIssue
                    || (
                        Table1[Issue_Date] = CurrentIssue
                        && Table1[Stat_ID] < CurrentID
                    )
                )
        )
    )
RETURN
IF (
    ISBLANK ( PrevExpiry ),
    BLANK (),
    IF ( CurrentIssue <= PrevExpiry, "Completed On Target", "Completed Outside of Target" )
)

 

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
GrowthNatives
Resolver III
Resolver III

Hi @RichOB,

We’ll add a calculated column that, per property, looks up the most recent previous Expiry_Date and compares it to the current Issue_Date.

Calculated column:

Status =
VAR CurrProp = 'Checks'[Property]
VAR CurrIssue = 'Checks'[Issue_Date]
VAR PrevExpiry =
CALCULATE(
MAX('Checks'[Expiry_Date]),
FILTER(
ALL('Checks'),
'Checks'[Property] = CurrProp
&& 'Checks'[Issue_Date] < CurrIssue
)
)
RETURN
IF(
ISBLANK(PrevExpiry),
BLANK(),
IF(CurrIssue <= PrevExpiry, "Completed On Target", "Completed Outside of Target")
)

Make sure Issue_Date and Expiry_Date are typed as Date.

This DAX logic leaves the first row for each property blank (since there’s no previous certificate), then marks entries as “Completed On Target” when the new Issue_Date is on or before the previous Expiry_Date, and as “Completed Outside of Target” when the new Issue_Date is after the previous Expiry_Date.

 

Hope this solution helps you make the most of Power BI! If it did, click 'Mark as Solution' to help others find the right answers.
💡Found it helpful? Show some love with kudos 👍 as your support keeps our community thriving!
🚀Let’s keep building smarter, data-driven solutions together! [Explore More]🚀

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.

Top Kudoed Authors