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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
lavdeepk
Resolver I
Resolver I

How to create calculated columns based on last year txn?

Hi All,

 

I need your help to create a calculated column based on conditions

 

Refer to the below sample data I have financial year-wise txn I want to categorize all txn based on condition. if any ref order exists in last year txn then mark it as "Partpayment"  Else "NO"  in the Part-payment Status field . (refer to desired results )

 

 

Please help me with the DAX formula to achieve desired results.

 

Ref No_FYPart-payment Status (desired results)
NK/20-21/011872 FY-20 NO
NK/20-21/006104 FY-20 NO
NK/19-20/146318 FY-20 NO
NK/20-21/002702 FY-20 NO
NK/20-21/001449 FY-21 NO
NK/20-21/014478 FY-21 NO
NK/20-21/006104 FY-21 Partpayment
NK/20-21/016876 FY-21 NO
NK/20-21/002702 FY-21 Partpayment
NK/19-20/134890 FY-21 NO
NK/20-21/000143 FY-21 NO
NK/20-21/008019 FY-21 NO
NK/19-20/106009 FY-22 NO
NK/19-20/083291 FY-22 NO
NK/20-21/000143 FY-22 Partpayment
NK/20-21/002906 FY-22 NO
NK/20-21/000292 FY-22 NO
NK/20-21/001449 FY-22 Partpayment
NK/20-21/006817 FY-22 NO
NK/20-21/014478 FY-22 Partpayment

 

Thanks

Lavdeep

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @lavdeepk ,

Try like below:

Step 1,import data,

Step 2, base on data ,create new column:

year = VALUE(RIGHT(TRIM('Table'[FY]),2))
No1 = RIGHT('Table'[Ref No_],6)

 

Step 3,if you want to create a new column ,use the below:

result =
IF (
    CALCULATE (
        COUNT ( 'Table'[No1] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[No1] = EARLIER ( 'Table'[No1] )
                && 'Table'[year] <= EARLIER ( 'Table'[year] )
                && 'Table'[year] > 'Table'[year] - 1
        )
    ) >= 2,
    "Partpayment",
    "No"
)

vluwangmsft_0-1627285131565.png

 

And if you want to create a new measure:

result2 =
IF (
    CALCULATE (
        COUNT ( 'Table'[No1] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[No1] = MAX ( 'Table'[No1] )
                && 'Table'[year] <= MAX ( 'Table'[year] )
                && 'Table'[year]
                    >= MAX ( 'Table'[year] ) - 1
        )
    ) >= 2,
    "Partpayment",
    "No"
)

 

 

vluwangmsft_1-1627285267110.png

Wish it is helpful for you!

 

Best Regards

Lucien

 

View solution in original post

1 REPLY 1
v-luwang-msft
Community Support
Community Support

Hi @lavdeepk ,

Try like below:

Step 1,import data,

Step 2, base on data ,create new column:

year = VALUE(RIGHT(TRIM('Table'[FY]),2))
No1 = RIGHT('Table'[Ref No_],6)

 

Step 3,if you want to create a new column ,use the below:

result =
IF (
    CALCULATE (
        COUNT ( 'Table'[No1] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[No1] = EARLIER ( 'Table'[No1] )
                && 'Table'[year] <= EARLIER ( 'Table'[year] )
                && 'Table'[year] > 'Table'[year] - 1
        )
    ) >= 2,
    "Partpayment",
    "No"
)

vluwangmsft_0-1627285131565.png

 

And if you want to create a new measure:

result2 =
IF (
    CALCULATE (
        COUNT ( 'Table'[No1] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[No1] = MAX ( 'Table'[No1] )
                && 'Table'[year] <= MAX ( 'Table'[year] )
                && 'Table'[year]
                    >= MAX ( 'Table'[year] ) - 1
        )
    ) >= 2,
    "Partpayment",
    "No"
)

 

 

vluwangmsft_1-1627285267110.png

Wish it is helpful for you!

 

Best Regards

Lucien

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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