Forum Discussion
RAnK conditioning problem
- 1 year ago
This was the solution
RANKX Agency 1 Pos =RANKX(FILTER(ADDCOLUMNS(SUMMARIZE(ALL(Industry[Agency], Industry[Advertiser]), -- Work at Agency and Advertiser levelIndustry[Agency],Industry[Advertiser]),"VariationAgencyTotal",CALCULATE([YTD Agency Variation],REMOVEFILTERS(Industry[Advertiser]) -- Evaluates variation at the Agency level),"ExcludeAdvertiser",IF(CALCULATE([YTD Agency Variation],REMOVEFILTERS(Industry[Advertiser])) > 0,FALSE(), -- Do not exclude if the Agency has a Positive VariationTRUE() -- Exclude if the Agency has Negative Variation)),[DeleteAdvertiser] = FALSE() -- Filter only Agency Advertisers with Positive Variation),CALCULATE([YTD Net Investment Agency],REMOVEFILTERS(Industry[Advertiser]) -- Ranking based on the Agency's total investment),,DESC,DENSE)
Okay, I got this formula that gives me the right result
RANKX Agency 1 Pos =
RANKX(
SUMMARIZE(
ALLSELECTED(Industry),
Industry[Advertiser],
Industry[Agency]),
CALCULATE([Net Investment YTD Agency],
REMOVEFILTERS(Industry[Advertiser]))
,
,
DESC
Turn
)
Now I need to exclude Agencies with Negative YoY, they should not appear in the ranking, and I try something like
RANKX Agency 1 Pos =
RANKX(
FILTER(
SUMMARIZE(
ALLSELECTED(Industry),
Industry[Advertiser],
Industry[Agency],
"InvestmentTotal", CALCULATE([Net Investment YTD Agency], REMOVEFILTERS(Industry[Advertiser])),
"VariacionTotal", CALCULATE([Variation YTD Agency], REMOVEFILTERS(Industry[Advertiser]))
),
[TotalVariation] > 0 -- Includes only agencies with positive variance
),
CALCULATE([Net Investment YTD Agency], REMOVEFILTERS(Industry[Advertiser])),
,
DESC
TURN
)
But the result is blank