Forum Discussion
Create a calculation based on a field in another column?
- 6 years ago
Hi, Anonymous
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may go to 'Query Editor' and create an index column as below.
You can try the following measures.
Total measure = var tab = ADDCOLUMNS( 'Table', "Result", IF( 'Table'[MILESTONE]="AUTHORISED", CALCULATE( SUM('Table'[TOTAL]), 'Table'[Index]=EARLIER('Table'[Index]) ) ) ) return SUMX( tab, [Result] )Percentage = var tab = ADDCOLUMNS( 'Table', "Result", var _index = CALCULATE( MAX('Table'[Index]), FILTER( ALL('Table'), 'Table'[Index]<EARLIER('Table'[Index])&& 'Table'[GROUP]=EARLIER('Table'[GROUP])&& 'Table'[TEAM]<>""&& 'Table'[CATEGORY]<>"" ) ) var _time = LOOKUPVALUE('Table'[TIME],'Table'[Index],_index) return IF( [MILESTONE]="AUTHORISED", DIVIDE(_time,[TOTAL]) ) ) return SUMX( tab, [Result] )Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, Anonymous
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may go to 'Query Editor' and create an index column as below.
You can try the following measures.
Total measure =
var tab =
ADDCOLUMNS(
'Table',
"Result",
IF(
'Table'[MILESTONE]="AUTHORISED",
CALCULATE(
SUM('Table'[TOTAL]),
'Table'[Index]=EARLIER('Table'[Index])
)
)
)
return
SUMX(
tab,
[Result]
)
Percentage =
var tab =
ADDCOLUMNS(
'Table',
"Result",
var _index =
CALCULATE(
MAX('Table'[Index]),
FILTER(
ALL('Table'),
'Table'[Index]<EARLIER('Table'[Index])&&
'Table'[GROUP]=EARLIER('Table'[GROUP])&&
'Table'[TEAM]<>""&&
'Table'[CATEGORY]<>""
)
)
var _time =
LOOKUPVALUE('Table'[TIME],'Table'[Index],_index)
return
IF(
[MILESTONE]="AUTHORISED",
DIVIDE(_time,[TOTAL])
)
)
return
SUMX(
tab,
[Result]
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous6 years agoNot applicable
Thank you so much for this, oddly, when I try and run the percentages measure - I get an error saying not enough memory to perform - could this be due to the size if the dataset?
- richbenmintz6 years ago
Resident Rockstar
Hi Anonymous,
Are you able to provide a sample pbix, really need to see what your data actually looks like.