Forum Discussion
Jessica_17
2 years agoHelper V
Max Column value based on another columns matching value
I have a table , where I want max month name where AL=CL=CU In this example September is the month which I want, regardless of any department Department Months AC CL CU 2 February 105 ...
- 2 years ago
pls try this
Measure = VAR tbl=ADDCOLUMNS('Table',"check",if('Table'[AC]='Table'[CL]&&'Table'[AC]='Table'[CU],1,0)) return FORMAT(maxx(FILTER(tbl,[check]=1),'Table'[Months]),"mmmm") - 2 years ago
pls try this
- 2 years ago
HI ryan_mayu
Thanks It worked for me.
- 2 years ago
pls try this
Measure = VAR _tbl = TOPN(1, SELECTCOLUMNS( FILTER( ADDCOLUMNS( 'Table', "Flag", INT( MIN( CALCULATE( MIN( 'Table'[AC] ) ), CALCULATE( MIN( 'Table'[CL] ) ) ) = CALCULATE( MIN( 'Table'[CU] ) ) ) ), [Flag] = 1 ), "@Month", 'Table'[Months], "@AC", 'Table'[AC] ),ABS([@AC])) RETURN MAXX(_tbl,[@Month])
Jessica_17
2 years agoHelper V
yes, depends on data, for negative right now it is september only, as max value works differently in negative right?
Ahmedx
2 years agoSuper User
I don't think I understand you but try again
- Jessica_172 years agoHelper V
HI Ahmedx
Suppose for this department , last matching values are -8 for september month, while using you query, it will show february, but I want september
as in negative value we would want minimum value instead of maximum value.
- Ahmedx2 years agoSuper User
pls try this
Measure = VAR _tbl = TOPN(1, SELECTCOLUMNS( FILTER( ADDCOLUMNS( 'Table', "Flag", INT( MIN( CALCULATE( MIN( 'Table'[AC] ) ), CALCULATE( MIN( 'Table'[CL] ) ) ) = CALCULATE( MIN( 'Table'[CU] ) ) ) ), [Flag] = 1 ), "@Month", 'Table'[Months], "@AC", 'Table'[AC] ),ABS([@AC])) RETURN MAXX(_tbl,[@Month])- Jessica_172 years agoHelper V
Hi Ahmedx
This worked, thank you so much for the help.