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
tdanielspbi
Frequent Visitor

Calculated Column to Calculate Date Per ID When Cumulative Sales Exceeds Target in Power BI

Hello Power BI Community,

 

I'm working on a project where I need to create a calculated column that calculates the date per ID when the cumulative sales have exceeded their respective target. I have two tables, Table 1 (budgets per ID) and the Sales Table (sales transactions). There is a one-to-many relationship between these tables.

 

Here's a sample of the data I'm working with:

Table 1 (Budgets per ID):

ID Target

11000
21500
32000

 

Sales Table (Sales Transactions):

ID Date Sales

12023-01-01300
12023-01-02400
12023-01-03350
22023-01-01500
22023-01-02600
22023-01-03450
32023-01-01800
32023-01-02700
32023-01-03600

 

I need a calculated column in Table 1 to show the date when the cumulative sales per ID have exceeded the target.

 

Any suggestions on how to create this calculated column in Power BI?

 

Thank you in advance for your help!

1 REPLY 1
FreemanZ
Super User
Super User

hi @tdanielspbi 

try to add a calculated column like:

 

Date = 
MINX(
    FILTER(
        RELATEDTABLE(Sales),
        VAR _date = Sales[Date]
        RETURN
            CALCULATE(
                SUM(Sales[Sales]),
                Sales[Date]<=_date,
                ALLEXCEPT(Sales,Sales[ID])
            )>=[Target]
    ),
    Sales[Date]
)

 

i slightly changed your Table1[Target] column to better verify the code. it worked like:

FreemanZ_0-1682171795559.png

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.