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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Jan-H
New Member

Problem with Creating new column based on multiple coditions

I need to generate a column in Maintenance that equals 1 if:

  1. Car is registered in 2010 (other table linked to maintenance table)
  2. Maintenance is done in for the first time in that year (if a car has multiple maintenances in a year it should only show a 1 for the first maintenance of that year)

 

JanH_0-1633084506578.png

 

@Anonymous 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Jan-H 

Car Table

3.png

Add a Year column in Matintenance Table.

2.png

Year = YEAR(Maintenance[Date of Maintenance])

Then try this code.

Flag 1 =
VAR _MinDateEachYear =
    CALCULATE (
        MIN ( Maintenance[Date of Maintenance] ),
        FILTER ( Maintenance, Maintenance[Year] = EARLIER ( Maintenance[Year] ) )
    )
RETURN
    IF (
        AND (
            RELATED ( Car[Registration year] ) = 2010,
            Maintenance[Date of Maintenance] = _MinDateEachYear
        ),
        1,
        BLANK ()
    )

Result is as below.

1.png

Best Regards,
Rico Zhou

 

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

2 REPLIES 2
Anonymous
Not applicable

Hi @Jan-H 

Car Table

3.png

Add a Year column in Matintenance Table.

2.png

Year = YEAR(Maintenance[Date of Maintenance])

Then try this code.

Flag 1 =
VAR _MinDateEachYear =
    CALCULATE (
        MIN ( Maintenance[Date of Maintenance] ),
        FILTER ( Maintenance, Maintenance[Year] = EARLIER ( Maintenance[Year] ) )
    )
RETURN
    IF (
        AND (
            RELATED ( Car[Registration year] ) = 2010,
            Maintenance[Date of Maintenance] = _MinDateEachYear
        ),
        1,
        BLANK ()
    )

Result is as below.

1.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

jppv20
Solution Sage
Solution Sage

Hi @Jan-H ,

 

Can you provide some example data from your table?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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