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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors