Forum Discussion

srlabhe's avatar
srlabhe
Super User
1 year ago
Solved

Finding Max Days per row

Hi PBI Gurus I have below data    Where Days CO is a measure calculated based on selected date in slicer like below = var _maxDate=[MaxAsOfDateSelected] var _diff= NETWORKDAYS(SELECTEDV...
  • danextian's avatar
    1 year ago

    Hi srlabhe 

    Try this:

    CO with top days = 
    CALCULATE (
        -- Get the CO with the highest [Days CO] in the current filter context
        MAXX (
            TOPN (
                1,
                -- Create a table of COs with their corresponding [Days CO] values
                SUMMARIZECOLUMNS ( 'Table'[CO], "@value", [Days CO] ),
                [@value], DESC  -- Sort descending by [Days CO] and take top 1
            ),
            [CO]  -- Return the CO name (could also use [@value] to return the max value)
        ),
        ALLSELECTED ()  -- Respect slicers and visuals while removing row context
    )