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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Help with IF statement for cumulative totals

Hi I would like to have a Cumulative Total calculate by Company.

 

My issue is that it is giving the cumulative total for the whole period and not differentiating by the Company type.

 

Capture.PNG

 

The formula I  used for the cumulative totals was as follows:

**bleep** Hrs To Date = CALCULATE(SUM(ACCOUNT_HISTORY[Hours To Date]),ALL(ACCOUNT_HISTORY),'ACCOUNT_HISTORY'[PERIOD]<=EARLIER('ACCOUNT_HISTORY'[PERIOD]))

 

**bleep** Cost To Date = CALCULATE(SUM(ACCOUNT_HISTORY[Cost To Date]),ALL(ACCOUNT_HISTORY),'ACCOUNT_HISTORY'[PERIOD]<=EARLIER('ACCOUNT_HISTORY'[PERIOD]))

 

Any ideas on how to add in an IF Function to do the cumulative by Company?

Sam

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I found a solution!!

 

Cumlt Hrs to Date Company = CALCULATE(SUM(ACCOUNT_HISTORY[Hours To Date]), ACCOUNT_HISTORY[PERIOD]<=EARLIER(ACCOUNT_HISTORY[PERIOD]),ALLEXCEPT(ACCOUNT_HISTORY, ACCOUNT_HISTORY [ACCOUNT.COMPANY]))

 

It works 🙂

View solution in original post

3 REPLIES 3
v-yuta-msft
Community Support
Community Support

@Anonymous,

 

 

To be general, you modify your measure using dax below and check if it can meet your requirement:

Hrs To Date =
CALCULATE (
    SUM ( ACCOUNT_HISTORY[Hours To Date] ),
    FILTER (
        ACCOUNT_HISTORY,
        'ACCOUNT_HISTORY'[ACCOUNT.COMPANY] = 'ACCOUNT_HISTORY'[ACCOUNT.COMPANY]
            && 'ACCOUNT_HISTORY'[PERIOD] <= EARLIER ( 'ACCOUNT_HISTORY'[PERIOD] )
    )
)

Cost To Date =
CALCULATE (
SUM ( ACCOUNT_HISTORY[Cost To Date] ),
FILTER (
ACCOUNT_HISTORY,
'ACCOUNT_HISTORY'[ACCOUNT.COMPANY] = 'ACCOUNT_HISTORY'[ACCOUNT.COMPANY]
&& 'ACCOUNT_HISTORY'[PERIOD] <= EARLIER ( 'ACCOUNT_HISTORY'[PERIOD] )
)
)

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

I found a solution!!

 

Cumlt Hrs to Date Company = CALCULATE(SUM(ACCOUNT_HISTORY[Hours To Date]), ACCOUNT_HISTORY[PERIOD]<=EARLIER(ACCOUNT_HISTORY[PERIOD]),ALLEXCEPT(ACCOUNT_HISTORY, ACCOUNT_HISTORY [ACCOUNT.COMPANY]))

 

It works 🙂

Anonymous
Not applicable

Thanks for the suggestion.

It still returned the same values as my original formula.

 

Any other ideas?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors