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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
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.