Forum Discussion
Calculated Column (Probability of Exceedance) Using Earlier Values
- 5 years ago
Hi v-janeyg-msft ,
I managed to solve this with a python script that outputs the data after processing the recursive calculation.
Turns out pandas is super powerful and it was a good learning experience 😄
Snippet of code from that column:
# Build pdep Column for i in range(0, (len(support))): if support.loc[i, 'IsNDValue']: na = 0 else: na = support.loc[i, 'Exposure Result mg_x'] nbj = support.loc[i, 'n_bj'] if i != 0: prev = support.loc[i - 1, 'pdep'] support.loc[i, 'pdep'] = prev + (1 - prev) * na / (na + nbj) else: prev = 0 support.loc[i, 'pdep'] = prev + (1 - prev) * na / (na + nbj)Thanks for your help.
Hi v-janeyg-msft ,
I managed to solve this with a python script that outputs the data after processing the recursive calculation.
Turns out pandas is super powerful and it was a good learning experience 😄
Snippet of code from that column:
# Build pdep Column
for i in range(0, (len(support))):
if support.loc[i, 'IsNDValue']:
na = 0
else:
na = support.loc[i, 'Exposure Result mg_x']
nbj = support.loc[i, 'n_bj']
if i != 0:
prev = support.loc[i - 1, 'pdep']
support.loc[i, 'pdep'] = prev + (1 - prev) * na / (na + nbj)
else:
prev = 0
support.loc[i, 'pdep'] = prev + (1 - prev) * na / (na + nbj)
Thanks for your help.
Hi, M4dsteve
I am very happy that you can use python to solve the problem, because dax is a data analysis language and is not suitable for calculation iteration. It is your ability to use multiple languages fluently.😆
You can mark your answer as solution.
Best Regards
Janey Guo