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
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
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.