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
DavidWaters100
Post Patron
Post Patron

Running total as a column but by year and Category also

Hi,

 

I need to tweak the below column calculation which is a running total.

 

The calculation is working but I also need it to work seperately per year and per "Type" in my data set.  At the moment it is just a running total of each month combined (the [Period]), regardless of the Year and "Type".

 

I can share a file if it helps - any help greatly appreciated.  I have to try to do this using a column, not a measure. 

 

Thanks! 

 

Running Total =
CALCULATE (
    SUM ( Sheet1[Amount] ),
    ALL(Sheet1),
    Sheet1[Period] <= EARLIER (Sheet1[Period])
)
 
Proud to be a Super User!
1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

You can just adapt your measure with ALLEXCEPT() in place of ALL().  Just include the columns you don't want to remove the filter from.  For example - ALLEXCEPT(Sheet1, Sheet1[Year]) will keep the current Year context in place. You can add 1 or move columns there.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
mahoneypat
Employee
Employee

You can just adapt your measure with ALLEXCEPT() in place of ALL().  Just include the columns you don't want to remove the filter from.  For example - ALLEXCEPT(Sheet1, Sheet1[Year]) will keep the current Year context in place. You can add 1 or move columns there.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi @mahoneypat 

 

Thanks for your reply - this worked for the year, but I can't get the category to work also which is "Ref" per below.  Any ideas what I am doing wrong please?  I get an error saying "cannot convert value Ref1 of type text to type True/False"?

 

Running Total =
CALCULATE (
    SUM ( Sheet1[Amount] ),
    ALLEXCEPT(Sheet1,Sheet1[Year]),Sheet1[Ref],
    Sheet1[Period] <= EARLIER (Sheet1[Period])
)
Proud to be a Super User!

Missed a bracket!  Thank you very much!

 

Running Total =
CALCULATE (
    SUM ( Sheet1[Amount] ),
    ALLEXCEPT(Sheet1,Sheet1[Year],Sheet1[Ref]),
    Sheet1[Period] <= EARLIER (Sheet1[Period])
)
Proud to be a Super User!

Both columns need to be listed in the ALLEXCEPT

 

ALLEXCEPT(Sheet1,Sheet1[Year],Sheet1[Ref]),

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.