Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello,
I am trying to calculate the Max Drawdown in a table of trades. A maximum drawdown (MDD) is the maximum loss from a peak to a trough of a portfolio, before a new peak is attained.
First, I calculate the cumulative profit with this measure:
Cumulative Profit$:= CALCULATE([TProfit$]; FILTER(ALLSELECTED('Calendar'); 'Calendar'[Date]<=MAX('Calendar'[Date])))
where TProfit$:=SUM(AllTrades[Profit$])
Then, I calculate the peak in the cumulative profit with this measure:
Peak:=MAXX(FILTER(ALLSELECTED('Calendar'); 'Calendar'[Date]<=MAX('Calendar'[Date])); [Cumulative Profit$])
Lastly, I calculate the max drawdown with this measure:
Max Drawdown:=MINX(AllTrades; [Cumulative Profit$]-[Peak])
In a test table with few rows these formulas are working correctly. The problem is the performance. If a table gets a bit larger then the formulas are running forever and finally a memory error occurs. This is probably because of the multiple iterations involved.
Does anyone has a suggestion for a max drawdown calculation with better performance? Thanks in advance.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 63 | |
| 55 | |
| 42 | |
| 41 | |
| 23 |
| User | Count |
|---|---|
| 167 | |
| 136 | |
| 120 | |
| 79 | |
| 54 |