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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
KTdataviz
New Member

Returning MAX of a column based on value of another column

Good afternoon! I am having a bit of trouble with my DAX syntax for what I'm trying to do. I would like to produce a calculated column with the MAX Tier Number for each Section, based on the Response column. In other words, in the table below, for Section C1, Tiers 1, 2, 3 have a positive response (1), but Tier 4 has a negative response (0), so the MAX Tier Number should be Tier 3. For Section C2, Tiers 1, 2, 3, 4 have a positive response, so the MAX Tier Number should be Tier 4. 

Section Num.ResponseTier NumberMax Tier
C1113
C1123
C1133
C1043
C2114
C2124
C2134
C2144

 

Max Tier = CALCULATE (
    MAX ( 'Survey'[Tier Num.] ),
    ALLEXCEPT ( 'Survey', 'Survey'[Section Num.] ), 'Survey'[Response] = 1
)

 

 Could someone please help me edit my formula to reflect the desired table above?

 

Thank you!

1 ACCEPTED SOLUTION
daXtreme
Solution Sage
Solution Sage

 

// Let the table be T.
// A good piece of good advice: 
//      Avoid the use of CALCULATE in calculated columns.
// The reason being speed and context transition control.

[Max Tier] = // calc column, not a measure
var CurrentSection = T[Section Num.]
var MaxTierWhereResponseIsOne =
    MAXX(
        FILTER(
            T,
            T[Section Num.] = CurrentSection
            && T[Response] = 1
        ),
        T[Tier Number]
    )
return
    MaxTierWhereResponseIsOne

 

View solution in original post

2 REPLIES 2
Luca_Yu
Regular Visitor

Hi @KTdataviz ,

Please try below DAX to create a new column:

Max Tier =
VAR cur_section = 'Table'[Section Num]
VAR tmp =
    FILTER ( 'Table', 'Table'[Section Num] = cur_section )
RETURN
    CALCULATE ( SUM ( 'Table'[Response] ), tmp )

Luca_Yu_0-1660032128054.png

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

daXtreme
Solution Sage
Solution Sage

 

// Let the table be T.
// A good piece of good advice: 
//      Avoid the use of CALCULATE in calculated columns.
// The reason being speed and context transition control.

[Max Tier] = // calc column, not a measure
var CurrentSection = T[Section Num.]
var MaxTierWhereResponseIsOne =
    MAXX(
        FILTER(
            T,
            T[Section Num.] = CurrentSection
            && T[Response] = 1
        ),
        T[Tier Number]
    )
return
    MaxTierWhereResponseIsOne

 

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.