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
Calais333
Regular Visitor

Calculated Column that returns the first value of another column, filtered by two columns.

Hi,

 

I need a calculated column that returns the first value from another column that is filtered by two additional columns. In excel I use the IF function. The table is a sample of what I am trying to achieve, the calculated column is "Result". 

 

IDLabelUnitResult
1000X11.51.5
1000X11.5 
1000X11.5 
1000B222
1000B22 
1000C31.81.8
1000C31.8 
1000C31.8 
1005X11.91.9
1005X11.9 
1005Z12.12.1
1005Z12.1 
1005Z12.1 
1005Z233
1005Z23 
1005C31.61.6
1008C31.6 
1008C31.6 
1008X122
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but I assume you have another column in the table that indicates which one is the first row in the group, for instance, a date column or an index column.

Please check the below picture and the attached pbix file.

 

 

Jihwan_Kim_0-1684041003248.png

 

Result CC = 
VAR _reference =
    CALCULATE (
        MAX ( Data[Index] ),
        INDEX (
            1,
            SUMMARIZE ( ALL ( Data ), Data[ID], Data[Label], Data[Unit], Data[Index] ),
            ORDERBY ( Data[Index], ASC ),
            KEEP,
            PARTITIONBY ( Data[ID], Data[Label] )
        )
    )
RETURN
    IF ( Data[Index] = _reference, Data[Unit] )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but I assume you have another column in the table that indicates which one is the first row in the group, for instance, a date column or an index column.

Please check the below picture and the attached pbix file.

 

 

Jihwan_Kim_0-1684041003248.png

 

Result CC = 
VAR _reference =
    CALCULATE (
        MAX ( Data[Index] ),
        INDEX (
            1,
            SUMMARIZE ( ALL ( Data ), Data[ID], Data[Label], Data[Unit], Data[Index] ),
            ORDERBY ( Data[Index], ASC ),
            KEEP,
            PARTITIONBY ( Data[ID], Data[Label] )
        )
    )
RETURN
    IF ( Data[Index] = _reference, Data[Unit] )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Excelent, that worked perfectly. Thanks!

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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