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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Kris55
New Member

Cumulative Sales by Agent for date range

Hi Everyone, 

 

I have looked everywhere, google ChatGPT but can't get anything to work. 

 

I need a DAX command to show the cumulative sales by agent by date for Q3-Q4 2023. 

 

Date               Agent   Value    Cumulative 

01/06/2023      A           10             10

02/06/2023      A          100           110

03/06/2023      A          325           435    

 

The problem is all dax commands I have seen up to now don't actually do what they say they will and look like this

 

Date               Agent   Value    Cumulative 

01/06/2023      A           10             10

02/06/2023      A          100           100

03/06/2023      A          325           325

 

This is what ChatGPT said but it feels like this DAX will only show sum for the date and not add up previous dates

 

Cumulative Sales = CALCULATE(
    SUM(opportunityproducts[Value (GBP)]),
    Filter(
        'opportunityproducts',
        'opportunityproducts'[Actual_Close_Date] >= MIN('Date'[Date]) &&
        'opportunityproducts'[Actual_Close_Date] <= MAX('Date'[Date]) &&
        'opportunityproducts'[Agent] = SELECTEDVALUE('opportunityproducts'[Agent])
    )
)
1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Kris55 

try to add a calculated column like:

Column = 
SUMX(
    FILTER(
        data,
        data[Agent]=EARLIER(data[Agent])
            &&data[Date]<=EARLIER(data[Date])
    ),
    data[Value]
)

or plot a table visual with columns and a measure like:

measure = 
SUMX(
    FILTER(
        ALLSELECTED(data),
        data[Agent]=MAX(data[Agent])
            &&data[Date]<=MAX(data[Date])
    ),
    data[Value]
)

it worked like:

FreemanZ_0-1698228972276.png

 

View solution in original post

2 REPLIES 2
FreemanZ
Super User
Super User

hi @Kris55 

try to add a calculated column like:

Column = 
SUMX(
    FILTER(
        data,
        data[Agent]=EARLIER(data[Agent])
            &&data[Date]<=EARLIER(data[Date])
    ),
    data[Value]
)

or plot a table visual with columns and a measure like:

measure = 
SUMX(
    FILTER(
        ALLSELECTED(data),
        data[Agent]=MAX(data[Agent])
            &&data[Date]<=MAX(data[Date])
    ),
    data[Value]
)

it worked like:

FreemanZ_0-1698228972276.png

 

Thank you so much FreemanZ, 

 

This has worked perfectly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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