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
tlhowell36
Regular Visitor

Running Count w/ 2 Measures

I need two measures:

1.  Running total of parts (based on a due date)

2.  Running total of completed parts (based on a completion date)

 

I need both of them in the same line graph visual.

 

Sample data would be:

Table:  AllParts

Columns:  Part Number, Status, Due Date, Completed Date

 

Part #          Status         Due Date          Completed Date

123              Done          1/15/18             1/17/18

456              Done          1/30/18              1/29/18

124              Done           2/6/18               1/30/18

125               Done          2/8/18               2/7/18

001                                  3/15/18

500                                  4/1/18

 

I did create a date table.

 

I am expecting my first line of total parts to show a line that has value 2 in Jan. 4 in Feb., 5 in March, and 6 in April (thus a running total)

 

The second line (those done) should have value 3 for Jan., 4 in Feb. and then a straight flat line from there.

 

Thank you PBI Community.

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

Hi tlhowell36,

 

Create two calculate columns using DAX formula like this:

Running total of Due Date = CALCULATE(COUNTROWS(AllParts), FILTER(AllParts, MONTH(AllParts[Due Date]) = MONTH(EARLIER(AllParts[Due Date])) && YEAR(AllParts[Due Date]) = YEAR(EARLIER(AllParts[Due Date]))))
Running total of Completed Date = CALCULATE(COUNTROWS(AllParts), FILTER(AllParts, AllParts[Status] = "Done" && MONTH(AllParts[Completed Date]) = MONTH(EARLIER(AllParts[Completed Date])) && YEAR(AllParts[Completed Date]) = YEAR(EARLIER(AllParts[Completed Date]))))

1.PNG2.PNG 

PBIX here: https://www.dropbox.com/s/auq44j0nxunexh8/Running%20Count.pbix?dl=0

 

Regards,

Jimmy Tao

View solution in original post

2 REPLIES 2
v-yuta-msft
Community Support
Community Support

Hi tlhowell36,

 

Create two calculate columns using DAX formula like this:

Running total of Due Date = CALCULATE(COUNTROWS(AllParts), FILTER(AllParts, MONTH(AllParts[Due Date]) = MONTH(EARLIER(AllParts[Due Date])) && YEAR(AllParts[Due Date]) = YEAR(EARLIER(AllParts[Due Date]))))
Running total of Completed Date = CALCULATE(COUNTROWS(AllParts), FILTER(AllParts, AllParts[Status] = "Done" && MONTH(AllParts[Completed Date]) = MONTH(EARLIER(AllParts[Completed Date])) && YEAR(AllParts[Completed Date]) = YEAR(EARLIER(AllParts[Completed Date]))))

1.PNG2.PNG 

PBIX here: https://www.dropbox.com/s/auq44j0nxunexh8/Running%20Count.pbix?dl=0

 

Regards,

Jimmy Tao

Greg_Deckler
Super User
Super User

Should be something along the lines of:

 

Running Total = 
VAR myDate = MAX('Calendar'[Date])
RETURN COUNTROWS(FILTER(ALL(Table1),[Due Date]<=myDate))

Completed Running Total = 
VAR myDate = MAX('Calendar'[Date])
RETURN COUNTROWS(FILTER(ALL(Table1),[Status]="Done" && [Completed Date]<=myDate))

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.