Forum Discussion
Yiyi
Helper I
3 years agoCan not calculate the running total with RANK function?
Hello all, I have created a summazied table for each media with its unique item count. I added rank as well for the purpose of calculating running total ( many media have the same value thus usi...
- Anonymous3 years ago
Hi Yiyi ,
According to your statement, I think [Unique_Item_Count] should be a column in your virtual table. So we couldn't use it directly in CALCULATE() without any aggregation.
Measure:
Pareto Test = VAR Total_Unique_Item = CALCULATE ( DISTINCTCOUNT ( 'Main Data'[HeadlineID] ), ALLSELECTED ( 'Main Data' ) ) VAR SummarizedTable = SUMMARIZE ( ALLSELECTED ( 'Main Data' ), 'Main Data'[Media], "Unique_Item_Count", DISTINCTCOUNT ( 'Main Data'[HeadlineID] ) ) VAR Summarizedtable_with_ranking = ADDCOLUMNS ( SummarizedTable, "Rank", RANK ( DENSE, SummarizedTable, ORDERBY ( [Unique_Item_Count], DESC, 'Main Data'[Media], ASC ), DEFAULT ) ) VAR CumulativeSum = SUMX ( FILTER ( Summarizedtable_with_ranking, [Rank] <= MAXX ( FILTER ( Summarizedtable_with_ranking, [Media] = MAX ( 'Main Data'[Media] ) ), [Rank] ) ), [Unique_Item_Count] ) RETURN DIVIDE ( CumulativeSum, Total_Unique_Item )Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
3 years agoNot applicable
Hi Yiyi ,
According to your statement, I think [Unique_Item_Count] should be a column in your virtual table. So we couldn't use it directly in CALCULATE() without any aggregation.
Measure:
Pareto Test =
VAR Total_Unique_Item =
CALCULATE (
DISTINCTCOUNT ( 'Main Data'[HeadlineID] ),
ALLSELECTED ( 'Main Data' )
)
VAR SummarizedTable =
SUMMARIZE (
ALLSELECTED ( 'Main Data' ),
'Main Data'[Media],
"Unique_Item_Count", DISTINCTCOUNT ( 'Main Data'[HeadlineID] )
)
VAR Summarizedtable_with_ranking =
ADDCOLUMNS (
SummarizedTable,
"Rank",
RANK (
DENSE,
SummarizedTable,
ORDERBY ( [Unique_Item_Count], DESC, 'Main Data'[Media], ASC ),
DEFAULT
)
)
VAR CumulativeSum =
SUMX (
FILTER (
Summarizedtable_with_ranking,
[Rank]
<= MAXX (
FILTER ( Summarizedtable_with_ranking, [Media] = MAX ( 'Main Data'[Media] ) ),
[Rank]
)
),
[Unique_Item_Count]
)
RETURN
DIVIDE ( CumulativeSum, Total_Unique_Item )
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.