Forum Discussion

rexxx428's avatar
rexxx428
Regular Visitor
1 year ago
Solved

[Power BI DAX] How to Build a Dynamic Equity Curve with Adjustable Entry and Exit Dates via Slicers?

I'm trying to create a dynamic equity curve in Power BI that simulates the return of buying a stock on a selected entry date and holding it until a selected exit date. Ideally, both dates should be controlled by slicers (from a shared DateTable), allowing users to interactively adjust the entry and exit points.

 

 

I worked extensively with ChatGPT to build the DAX logic, but after a long back-and-forth, the result still didn’t produce the expected curve. I also searched online, but most examples were for static return calculations, not truly dynamic with slicer-based control over the entry/exit period.

 

Example of What I Want:

Each cell represents the return from the selected entry date (column) to a later date (row), calculated as:

 

(Latest Price - Entry Price) / Entry Price

 

DatePrice Enter on Jun 2Enter on Jun 3Enter on Jun 4Enter on Jun 5
6/2/2025$50.00 0.0%N/AN/AN/A
6/3/2025$52.00 4.0%0.0%N/AN/A
6/4/2025$54.00 8.0%3.8%0.0%N/A
6/5/2025$51.00 2.0%-1.9%-5.6%0.0%
6/6/2025$56.00 12.0%7.7%3.7%9.8%
6/9/2025$48.00 -4.0%-7.7%-11.1%-5.9%
6/10/2025$55.00 10.0%5.8%1.9%7.8%
6/11/2025$60.00 20.0%15.4%11.1%17.6%

 

My Questions:

  • How can I write a DAX measure (or matrix setup) that dynamically computes return between two slicer-selected dates?

  • Is there a way to create a proper equity curve that updates per row in a line chart (or matrix) based on slicer-driven entry and exit date?

 

Any working example, workaround, or DAX design pattern would be hugely appreciated.

Thanks in advance!

  • Thankyou, johnt75, for your response.

    Hi rexxx428,

    We appreciate your question on the Microsoft Fabric Community Forum.

    Please find the attached screenshot and sample PBIX file:

    We hope this information helps you to resolve the issue. If you have any more questions, please feel free to ask the Microsoft Fabric community.

    Thank you.

  • Hi rexxx428,

    Thank you for the update.

    We are following up to see if your query has been resolved. If our response was helpful, please mark it as the accepted solution, as this helps the broader community.

    Should you have any further queries, kindly feel free to contact the Microsoft Fabric community.


    Thank you.

6 Replies

  • Create 2 disconnected tables with dates to use for the entry and exit date slicers. Assuming that you have a measure which will return the price for a given date, you can create a measure like

    Projected Return =
    VAR EntryDate =
        SELECTEDVALUE ( 'Entry Date'[Date] )
    VAR ExitDate =
        SELECTEDVALUE ( 'Exit Date'[Date] )
    VAR CurrentDate =
        MAX ( 'Date'[Date] )
    VAR Result =
        IF (
            EntryDate <= CurrentDate
                && (
                    ISBLANK ( ExitDate )
                        || ExitDate >= CurrentDate
                ),
            VAR EntryPrice =
                CALCULATE ( [Price], 'Date'[Date] = EntryDate )
            VAR CurrentPrice = [Price]
            VAR Result =
                DIVIDE ( CurrentPrice - EntryPrice, EntryPrice )
            RETURN
                Result
        )
    RETURN
        Result
    

    and then put that in a visual with columns from the main date table.

  • v-pnaroju-msft's avatar
    v-pnaroju-msft
    Icon for Community Support rankCommunity Support

    Thankyou, johnt75, for your response.

    Hi rexxx428,

    We appreciate your question on the Microsoft Fabric Community Forum.

    Please find the attached screenshot and sample PBIX file:

    We hope this information helps you to resolve the issue. If you have any more questions, please feel free to ask the Microsoft Fabric community.

    Thank you.

  • rexxx428's avatar
    rexxx428
    Regular Visitor

    Thank you so much for replying!! It helps a lot. I really appreciate it.

    • v-pnaroju-msft's avatar
      v-pnaroju-msft
      Icon for Community Support rankCommunity Support

      Hi rexxx428,

      Thank you for the update.

      We are following up to see if your query has been resolved. If our response was helpful, please mark it as the accepted solution, as this helps the broader community.

      Should you have any further queries, kindly feel free to contact the Microsoft Fabric community.


      Thank you.

  • v-pnaroju-msft's avatar
    v-pnaroju-msft
    Icon for Community Support rankCommunity Support

    Hi rexxx428,

    We are following up to check if your query has been resolved. If our response was helpful, please mark it as the accepted solution, as this will benefit the wider community.

    If you have any further queries, please feel free to reach out to the Microsoft Fabric community.

    Thank you.

  • Hi,

    Share some raw data to work with.  The table that you have shared in your original post looks like the expected result.