Forum Discussion
Filtering Table Values
- 4 years ago
Anonymous this will be table expression
Table 2 = var _grp = GROUPBY('Table','Table'[GUID],'Table'[LPGU],"subTotal by GUIDLPGU",SUMX(CURRENTGROUP(),'Table'[Order Value])) --var _filt = TOPN(1, FILTER(_grp,var _guid = [GUID] return [GUID]=_guid),[x],DESC) var _rank = SUMMARIZE(FILTER(ADDCOLUMNS(_grp, "rank", RANKX(FILTER(_grp,[GUID]=EARLIER([GUID])),[subTotal by GUIDLPGU],,DESC)),[rank]=1),[GUID],[LPGU],[subTotal by GUIDLPGU]) return _rankAlexisOlson in a table expression is it possible to ask TOPN to return TOPN(1) based on a partiton like in RANKX
RANKX(FILTER(_grp,[GUID]=EARLIER([GUID])I tried but failed.
Anonymous you can write a measure like this
_Measure =
CALCULATE (
CALCULATE (
SUM ( 'Table'[Order Value] ),
ALLEXCEPT ( 'Table', 'Table'[GUID], 'Table'[LPGU] )
),
KEEPFILTERS (
TOPN (
1,
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[GUID] = MAX ( 'Table'[GUID] ) ),
CALCULATE (
SUM ( 'Table'[Order Value] ),
ALLEXCEPT ( 'Table', 'Table'[GUID], 'Table'[LPGU] )
), DESC
)
)
)
smpa01 This looks good. Can we implement this as Calculated Table with all 3 columns?
- smpa014 years agoCommunity Champion
Anonymous this will be table expression
Table 2 = var _grp = GROUPBY('Table','Table'[GUID],'Table'[LPGU],"subTotal by GUIDLPGU",SUMX(CURRENTGROUP(),'Table'[Order Value])) --var _filt = TOPN(1, FILTER(_grp,var _guid = [GUID] return [GUID]=_guid),[x],DESC) var _rank = SUMMARIZE(FILTER(ADDCOLUMNS(_grp, "rank", RANKX(FILTER(_grp,[GUID]=EARLIER([GUID])),[subTotal by GUIDLPGU],,DESC)),[rank]=1),[GUID],[LPGU],[subTotal by GUIDLPGU]) return _rankAlexisOlson in a table expression is it possible to ask TOPN to return TOPN(1) based on a partiton like in RANKX
RANKX(FILTER(_grp,[GUID]=EARLIER([GUID])I tried but failed.
- AlexisOlson4 years agoSuper User
I'm not quite sure what you mean but you can simplify your _rank variable to be:
FILTER ( _grp, RANKX ( FILTER ( _grp, [GUID] = EARLIER ( Table1[GUID] ) ), [subTotal by GUIDLPGU] ) = 1 )or like this
TOPN ( 1, _grp, RANKX ( FILTER ( _grp, [GUID] = EARLIER ( Table1[GUID] ) ), [subTotal by GUIDLPGU] ), ASC )- smpa014 years agoCommunity Champion
AlexisOlson Thanks. I was not asking you about RANKX. I was wondering if it is possible to pass on a partitoned table in TOPN like I did in RANKX?
Can I pass on a similar table like following in TOPN, so that TOPN (1) gives me thre result for that partiton?
RANKX ( FILTER ( _grp, [GUID] = EARLIER ( Table1[GUID] ) )