cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cardonasebast
Frequent Visitor

Running Values with Month and Value

Hi. 

 

I have a problem creating a Running Value in DAX. I need to group by month and value (for this case a Project) but most of the solutions in the community forum are releated to grouping by date and not by date and value as i need in this case.

 

For example:

 

PowerBi.JPG

 

The correct Running Value for me must be by month and Project , for example:

 

 

 PowerBi2.JPG

 

I used this DAX formulas:

 

AcumT = CALCULATE(SUM(PptoxMes[Presupuesto]);FILTER(PptoxMes;PptoxMes[Month_Num]<=EARLIER(PptoxMes[Month_Num]));PptoxMes[Año]="2015";values(PptoxMes[Proyecto]))

 

and this:

 

AcumT = CALCULATE(SUM(PptoxMes[Presupuesto]);FILTER(PptoxMes;PptoxMes[Month_Num]<=EARLIER(PptoxMes[Month_Num])))

 

and this solution:

 

http://community.powerbi.com/t5/Desktop/DAX-Running-total-by-another-column/td-p/10512

 

and nothing works for me.

 

I need your help.

 

Thanks a lot.

2 ACCEPTED SOLUTIONS
OwenAuger
Super User
Super User

Hi there,

 

For a running total in a DAX calculated column, I find the safest way is to use ALLEXCEPT to ensure that only the columns you specify remain in the filter context for each running total.

 

In your case I would use:

AcumT =
CALCULATE (
    SUM ( PptoxMes[Presupuesto] );
    ALLEXCEPT ( PptoxMes; PptoxMes[Año]; PptoxMes[Projecto] );
    PptoxMes[Month_Num] <= EARLIER ( PptoxMes[Month_Num] )
)

Does that do the trick?

 

Owen 🙂


Owen Auger

Did I answer your question? Mark my post as a solution!

My Blog
Connect on Twitter
Connect on LinkedIn

View solution in original post

Sean
Community Champion
Community Champion

@cardonasebast Look at the picture... Both of my formulas are Measures.

Running Total by Project.png

 

EDIT: You should probably add the Year field in the Matrix like this... so data is not aggregated by Month for all years

Running Total by Project2.png

 

View solution in original post

2 REPLIES 2
Sean
Community Champion
Community Champion

@cardonasebast Look at the picture... Both of my formulas are Measures.

Running Total by Project.png

 

EDIT: You should probably add the Year field in the Matrix like this... so data is not aggregated by Month for all years

Running Total by Project2.png

 

OwenAuger
Super User
Super User

Hi there,

 

For a running total in a DAX calculated column, I find the safest way is to use ALLEXCEPT to ensure that only the columns you specify remain in the filter context for each running total.

 

In your case I would use:

AcumT =
CALCULATE (
    SUM ( PptoxMes[Presupuesto] );
    ALLEXCEPT ( PptoxMes; PptoxMes[Año]; PptoxMes[Projecto] );
    PptoxMes[Month_Num] <= EARLIER ( PptoxMes[Month_Num] )
)

Does that do the trick?

 

Owen 🙂


Owen Auger

Did I answer your question? Mark my post as a solution!

My Blog
Connect on Twitter
Connect on LinkedIn

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors