Forum Discussion
Running Total
- 4 years ago
LiborK
So, no calculated columns. Create this measure:Count RT = VAR _current_count = [COUNT ID'S] VAR _current_id = SELECTEDVALUE('Table'[ID]) VAR _max_customer_id = ROUND(CALCULATE(MAX('Table'[ID]), ALLSELECTED('Table'[ID]),-1) VAR _ranking_table = ADDCOLUMNS( ALLSELECTED('Table'[ID]), "@%ID", [% ID], "@Ranking", [COUNT ID'S] * _max_customer_id + 'Table'[ID] ) VAR _current_rank = _current_sales * _max_customer_id + _current_id VAR _result = SUMX( FILTER( _ranking_table, [@Ranking] >= _current_rank ), [@%ID] ) RETURN _result - 4 years ago
Hi LiborK,
You may try this solution.
Here are the Measures created.
Count ID = CALCULATE(COUNT('Table'[ID]),ALLEXCEPT('Table','Table'[ID])) Total Count of IDs = CALCULATE(COUNT('Table'[ID]),ALL('Table')) %ID = DIVIDE([Count ID],'Table'[Total Count of IDs]) Wished Running Sum = CALCULATE([%ID],FILTER(ALL('Table'),'Table'[RANK]>=MAX('Table'[RANK])))Here are the Calculated columns created.
DistinctCountID =CALCULATE(COUNT('Table'[ID]),FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID]))) RANK = VAR MaxID = CALCULATE ( MAX ( 'Table'[ID] ), ALLEXCEPT ( 'Table', 'Table'[DistinctCountID] ) ) VAR Addition = ROUND ( 'Table'[%ID], 5 ) * 100000 RETURN IF ( 'Table'[ID] < MaxID, Addition + MaxID, Addition )Then, the result look like this.
Also, attach the pbix file as reference.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!
Best Regards,
Community Support Team _ Caiyun
LiborK
So, no calculated columns. Create this measure:
Count RT =
VAR _current_count = [COUNT ID'S]
VAR _current_id = SELECTEDVALUE('Table'[ID])
VAR _max_customer_id =
ROUND(CALCULATE(MAX('Table'[ID]), ALLSELECTED('Table'[ID]),-1)
VAR _ranking_table =
ADDCOLUMNS(
ALLSELECTED('Table'[ID]),
"@%ID", [% ID],
"@Ranking", [COUNT ID'S] * _max_customer_id + 'Table'[ID]
)
VAR _current_rank = _current_sales * _max_customer_id + _current_id
VAR _result =
SUMX(
FILTER(
_ranking_table,
[@Ranking] >= _current_rank
),
[@%ID]
)
RETURN
_result
Thank you so much for your help, but it is still not working...I will try to describe it in different way.
I have just table with this column "ID" and values in this column are with structure like in picture below ( for example 13, can be there multiple times) and I dont have there any other measures.
And my task is to create table where in first column will be ID (for each row unique ID) and the rest of the column will be like in picture 2
and I am able to create measures for column B-E, but I am not able to create measure for column F.
VAR _ranking_table =
ADDCOLUMNS(
ALLSELECTED('Table'[ID]),
"@%ID"(parametr is not in correct type), [% ID](I am not able to find the measure, it provide me just standard column from model),
"@Ranking", [COUNT ID'S] * _max_customer_id + 'Table'[ID]
)