Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
aaftab42
Frequent Visitor

Issue with Calculating Drawdown with Filters in Power BI

Hi Community Members,

I'm currently working on a Power BI project and could use some guidance on optimizing my drawdown calculations. Here's a summary of my approach and the challenge I'm facing:

Current Approach

1. Summarized Table

Created a summarized table to reduce dataset size:

DailySummary = 
SUMMARIZE(
    four_strategy,
    four_strategy[Entry_Date],
    "DailySummaryTotalProfit", [AdjustedTotalProfit]
)

2. Cumulative Profit Measure

Calculated cumulative profit:

DailyCumulativeProfit = 
CALCULATE(
    SUMX(
        FILTER(
            ALL(DailySummary),
            DailySummary[Entry_Date] <= MAX(DailySummary[Entry_Date])
        ),
        [AdjustedTotalProfit]
    )
)

3. Running Max Profit

Created a measure for running max profit:

RunningMaxProfit = 
CALCULATE(
    MAXX(
        FILTER(
            ALL(DailySummary),
            DailySummary[Entry_Date] <= MAX(DailySummary[Entry_Date])
        ),
        [DailyCumulativeProfit]
    )
)

4. Daily Drawdown

Finally, calculated the daily drawdown:

DailyDrawdown = 
[DailyCumulativeProfit] - [RunningMaxProfit]

Issue

The current approach works well without filters. However, when applying filters like specific years or days, the results are invalid. Using ALLSELECTED works for granular filters but leads to query exceeded errors when more filters are applied (e.g., filtering more than 2 years out of 5 years of data).

 

I'm looking for a solution to calculate the drawdown accurately while handling filters without exceeding memory limits. Any suggestions or best practices on optimizing these calculations would be greatly appreciated.

Thank you in advance for your help!

6 REPLIES 6
manoj_kumar95
New Member

I am using the same formulas for cummulative sum and max but the cummulative max is not working i dont know the reason. it is taking the same values through out the data though the data is changed in asecnding or descding ordrer. Please help me with that.

I am attaching the project file, the screenshots and the formulas below.

Link:- https://drive.google.com/file/d/19TmkeaslWT-KueSMjnDZO3QVjVOl0ApP/view?usp=sharing

manoj_kumar95_0-1748028042083.pngmanoj_kumar95_1-1748028044660.png

DailyCumulativeProfit =
CALCULATE(
    SUMX(
        FILTER(
            ALL(trade_logs),
            trade_logs[date] <= MAX(trade_logs[date]
            )
        ),
        trade_logs[pnl]
    )
)
 
RunningMaxPnL =
CALCULATE(
    MAXX(
        FILTER(
            ALL(trade_logs),
           trade_logs[date] <= MAX(trade_logs[date]
            )
        ),
        [DailyCumulativeProfit]
    )
)

Hi,

Show the expected result very clearly.

I have attached the screenshots and pbix file. I need to get the correct running max. But y using the above formula i am not getting.

In this example see the dailycummulativeprofit and RunningMaxProfit 

1st image when not sorted

2nd image when dailycummulative profit sorted ascending

3rd image when dailycummulativeprofit column sorted descending 

in all these three cases the running max is changing dynamically but in my case it isnt changing it is giving a constant value all over the rows.

I am again attaching my power bi file once please refer to it and please help me out.

Link:- https://drive.google.com/file/d/19TmkeaslWT-KueSMjnDZO3QVjVOl0ApP/view?usp=sharing

 

when not sortedwhen not sorted

 

When cummulativeprofit sorted ascendingWhen cummulativeprofit sorted ascending

 

When cumulativeprofit column sorted descendingWhen cumulativeprofit column sorted descending

 

Hi,

You have still not answered my previous question - you do not show the expected result at all.  Anyways, based on whatever my understanding is, download the PBI file from here.

Ashish_Excel_0-1748066700966.png

 

TomMartens
Super User
Super User

Hey @aaftab42 ,

 

please provide a pbix that contains sample data, but still reflects your semantic model (tables, relationships, calculated columns, and measures). Upload the pbix to OneDrive, Google Drive, or Dropbox and share the link. If you are using spreadsheet to create the sample data instead of the manual import method, share the spreadsheet as well.

 

Do not forget to describe the expected result based on the sample data you provide.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi Tom,

I hope this message finds you well.

I have encountered an issue with the calculation of drawdown in my Power BI report, and I would appreciate any guidance or advice you could offer.

Details of the Issue:

  • Data Structure: I have three files:
    • four_strategy: This is the fact table.
    • indices: This is a category table.
    • strategy: This is a sub-category table.
  • Measures Involved:
    • cumulativeprofit
    • running max profit
    • dailydrawdown

Problems:

  • If the first day shows a negative value in profit and loss, it does not mark it as a drawdown.
  • Applying filters to specific years or days results in incorrect calculations due to the use of the ALL function, which does not adhere to the filters. Using ALLSELECTED to fix this issue leads to memory exceed errors.

Objective:

I would like to have an accurate drawdown calculation in a line chart that reflects the drawdown under different filters, similar to how the total profit is displayed.

Files and Data:

I have created a sample .pbix file that includes the tables, relationships, calculated columns, and measures. Additionally, I am providing spreadsheets with sample data to better illustrate the issue. The files are available at the following link:

Google Drive Link

Expected Result:

The goal is to accurately calculate and display the drawdown in a line chart, while correctly responding to different filters applied to the data, such as specific years or days, without causing memory issues.

Thank you in advance for your support and assistance.

Best regards,
Aaftab Ahmad

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors