Forum Discussion

johanthedataman's avatar
johanthedataman
Frequent Visitor
7 years ago
Solved

Max Value for 2 Filters

Hi there,

 

I have a question. I have the following dataset:

IDCodeOpportunityIDModifiedYearMonthStageID
142SF000020204/10/192019/045
106SF000020204/4/192019/044
105SF000020204/4/192019/044
99SF000020203/29/192019/034
98SF000020203/29/192019/033
87SF000020203/25/192019/032
86SF000020203/25/192019/032
85SF000020203/25/192019/031

 

I want to know in a calculated column: the highest StageID per Code per month. In this example, the Code is filtered on 'SF00020', but in my dataset there are much more Codes. 

 

So the solution should provide me for April StageID 5 and for March StageID 4.

 

I tried a few calculate(max(filter-options, but I couldn't solve the problem.

 

Cheers,

 

Johan

  • Hi,

    Try this calculated column formula

    =CALCULATE(MAX(Data[StageID]),FILTER(Data,Data[Code]=EARLIER(Data[Code])&&Data[YearMonth]=EARLIER(Data[YearMonth])))

    Hope this helps.

2 Replies

  • johanthedataman add new measure using following expression

     

    Max Stage = 
    CALCULATE( 
    MAX( Table4[StageID] ),
     ALLEXCEPT( Table4, Table4[Code], Table4[YearMonth] ) 
    )
  • Hi,

    Try this calculated column formula

    =CALCULATE(MAX(Data[StageID]),FILTER(Data,Data[Code]=EARLIER(Data[Code])&&Data[YearMonth]=EARLIER(Data[YearMonth])))

    Hope this helps.