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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
johnbasha33
Super User
Super User

Running total for multiple filters

Hi,

 

I am running out of ideas here, can you please help me with the below.

if you notice below i want to show the running total for no cases opened based on inception date for each year.

but here is the catch. year(inceptiondate)<> year(resolution date) and also we shoud check if there is any case opened previous year and got closed in the selected year. 

for example in line chart, 2014 has 3 resolution dates in the left table it means, all those 3 are not valid. we should see only 1 for 2014 in line chart, that one record belongs to 2012. same count i need to get for all years as a running total. how to achieve this? 

 

johnbasha33_0-1710777811236.png

MatterIDInceptionDateResolutionDate
20111128-68511/28/20111/20/2014
20120905-6849/5/20125/8/2023
20131001-68310/1/20137/1/2014
20140101-6821/1/20141/1/2014
20150401-6814/1/20155/3/2022


@talespin @lbendlin @123abc @Jihwan_Kim @Greg_Deckler @amitchandak 

1 ACCEPTED SOLUTION

hi @johnbasha33 

 

My Apology, but I am not sure if I have understood your requirement correctly.

You want running total(Count) until you see a case closure(Created year = closed year), if that happens you want to reset running total(Count)?

 

Below Calculated Column will return count based on what I have stated above.

 

Active Count =
VAR _CreatedDate = 'Actual Data'[Created Date]
VAR _MaxClosedDate = CALCULATE( MAX('Actual Data'[Created Date]), REMOVEFILTERS(), YEAR('Actual Data'[Created Date]) = YEAR('Actual Data'[Closed Date]) && 'Actual Data'[Created Date] <= _CreatedDate)
VAR _MinClosedDate = CALCULATE( MIN('Actual Data'[Created Date]), REMOVEFILTERS())
VAR _ClosedDate = IF( ISBLANK(_MaxClosedDate), _MinClosedDate, _MaxClosedDate)
RETURN CALCULATE( COUNT('Actual Data'[CaseID]), REMOVEFILTERS(), 'Actual Data'[Created Date] >= _MaxClosedDate && 'Actual Data'[Created Date] <= _CreatedDate)
-----------------------------------------------------------------------------------------------------
If you want it as a measure.
 
Actice Count New =
VAR _CreatedDate = SELECTEDVALUE('Actual Data'[Created Date])
VAR _MaxClosedDate = CALCULATE( MAX('Actual Data'[Created Date]), REMOVEFILTERS(), YEAR('Actual Data'[Created Date]) = YEAR('Actual Data'[Closed Date]) && 'Actual Data'[Created Date] <= _CreatedDate)
VAR _MinClosedDate = CALCULATE( MIN('Actual Data'[Created Date]), REMOVEFILTERS())
VAR _ClosedDate = IF( ISBLANK(_MaxClosedDate), _MinClosedDate, _MaxClosedDate)
RETURN CALCULATE( COUNT('Actual Data'[CaseID]), REMOVEFILTERS(), 'Actual Data'[Created Date] >= _MaxClosedDate && 'Actual Data'[Created Date] <= _CreatedDate)
 
talespin_0-1711085610604.pngtalespin_0-1711086009895.png

 

 

View solution in original post

20 REPLIES 20
talespin
Solution Sage
Solution Sage

hi @johnbasha33 

 

My apology, but I am unable to understand requirement.

Hi @talespin  it is little hard and complex as i mentioned before, how about we can have a quick call ...

Anonymous
Not applicable

Hi, @johnbasha33 

Have you solved your problem? If so, can you share your solution here and mark the correct answer as a standard answer to help other members find it faster? Thank you very much for your kind cooperation!

Best Regards

Yongkang Hua

@Anonymous still dint have any solution for this, it is a complex scenario. so looking for any solutions. 

Anonymous
Not applicable

Hi, @johnbasha33

Your original need, described by talespin in the 9th Reply has already solved your original need, please consider mark's scenario. The latter ones belong to the new requirements, and you can consider opening a new case.

Best Regards

Yongkang Hua

 

talespin
Solution Sage
Solution Sage

hi @johnbasha33 

 

Sorry, I am unable to understand the requirement.

 

Understood

if you notice below i want to show the running total for no cases opened based on inception date for each year. 

 

Please explain below in detail. What do you mean by case, closed, selected year?

Please share pbix file with mock data.

 

"but here is the catch. year(inceptiondate)<> year(resolution date) and also we shoud check if there is any case opened previous year and got closed in the selected year. 

for example in line chart, 2014 has 3 resolution dates in the left table it means, all those 3 are not valid. we should see only 1 for 2014 in line chart, that one record belongs to 2012. same count i need to get for all years as a running total. how to achieve this?".

@talespin thanks for showing interest in this, attaching the pbix with more detailed explanation.

 

https://drive.google.com/file/d/1-6crHQAZAbiD3YEKynvjdny_wlL-HhJT/view?usp=sharing

@lbendlin @Jihwan_Kim @amitchandak 

hi @johnbasha33 

 

My Apology, but I am not sure if I have understood your requirement correctly.

You want running total(Count) until you see a case closure(Created year = closed year), if that happens you want to reset running total(Count)?

 

Below Calculated Column will return count based on what I have stated above.

 

Active Count =
VAR _CreatedDate = 'Actual Data'[Created Date]
VAR _MaxClosedDate = CALCULATE( MAX('Actual Data'[Created Date]), REMOVEFILTERS(), YEAR('Actual Data'[Created Date]) = YEAR('Actual Data'[Closed Date]) && 'Actual Data'[Created Date] <= _CreatedDate)
VAR _MinClosedDate = CALCULATE( MIN('Actual Data'[Created Date]), REMOVEFILTERS())
VAR _ClosedDate = IF( ISBLANK(_MaxClosedDate), _MinClosedDate, _MaxClosedDate)
RETURN CALCULATE( COUNT('Actual Data'[CaseID]), REMOVEFILTERS(), 'Actual Data'[Created Date] >= _MaxClosedDate && 'Actual Data'[Created Date] <= _CreatedDate)
-----------------------------------------------------------------------------------------------------
If you want it as a measure.
 
Actice Count New =
VAR _CreatedDate = SELECTEDVALUE('Actual Data'[Created Date])
VAR _MaxClosedDate = CALCULATE( MAX('Actual Data'[Created Date]), REMOVEFILTERS(), YEAR('Actual Data'[Created Date]) = YEAR('Actual Data'[Closed Date]) && 'Actual Data'[Created Date] <= _CreatedDate)
VAR _MinClosedDate = CALCULATE( MIN('Actual Data'[Created Date]), REMOVEFILTERS())
VAR _ClosedDate = IF( ISBLANK(_MaxClosedDate), _MinClosedDate, _MaxClosedDate)
RETURN CALCULATE( COUNT('Actual Data'[CaseID]), REMOVEFILTERS(), 'Actual Data'[Created Date] >= _MaxClosedDate && 'Actual Data'[Created Date] <= _CreatedDate)
 
talespin_0-1711085610604.pngtalespin_0-1711086009895.png

 

 

Hi @talespin  thank you so much for your valuable time in this for me. it was briliant. calculation seems to be right for begining. but when i added the whole data, calculation seems to be off starting from year 2017 suddenly the count dropped to 1. that seems to be wrong. 

now we also have open cases. 
can you please help me fix the logic for closed ones and finally we need to take the count of cases for open cases and club both count for each year. 

 

really appreciate if you can share it, attaching the new file here.

 

https://drive.google.com/file/d/1-6crHQAZAbiD3YEKynvjdny_wlL-HhJT/view?usp=sharing

 

hi @johnbasha33 

 

Please apply status filter.

 

Actice Count New =
VAR _CreatedDate =
    SELECTEDVALUE ( 'Actual Data'[Created Date] )
VAR _MaxClosedDate =
    CALCULATE (
        MAX ( 'Actual Data'[Created Date] ),
        REMOVEFILTERS(),
        'Actual Data'[Status] = "Closed",
        YEAR ( 'Actual Data'[Created Date] ) = YEAR ( 'Actual Data'[Closed Date] )
            && 'Actual Data'[Created Date] <= _CreatedDate
    )
VAR _MinClosedDate =
    CALCULATE ( MIN ( 'Actual Data'[Created Date] ), REMOVEFILTERS(), 'Actual Data'[Status] = "Closed" )
VAR _ClosedDate =
    IF ( ISBLANK ( _MaxClosedDate ), _MinClosedDate, _MaxClosedDate )
RETURN
    CALCULATE (
        COUNT ( 'Actual Data'[CaseID] ),
        REMOVEFILTERS(),
        'Actual Data'[Status] = "Closed",
        'Actual Data'[Created Date] >= _ClosedDate
            && 'Actual Data'[Created Date] <= _CreatedDate
    )
 
talespin_0-1711188234587.png

 

@talespin requirement has changed now, earlier we are not counting year(created)=year(closed).
but now we need to count them as well.
here is the expected output. how can we alter the logic now?

johnbasha33_0-1711470509156.png

 

 
Please try this measure.
 
Active Count2 =
VAR _CreatedDate =
    SELECTEDVALUE ( 'Actual Data'[Created Date] )
VAR _MaxClosedDate =
    CALCULATE (
        MAX ( 'Actual Data'[Created Date] ),
        REMOVEFILTERS(),
        'Actual Data'[Status] = "Closed",
        YEAR ( 'Actual Data'[Created Date] ) = YEAR ( 'Actual Data'[Closed Date] )
            && 'Actual Data'[Created Date] < _CreatedDate
    )
VAR _MinClosedDate =
    CALCULATE ( MIN ( 'Actual Data'[Created Date] ), REMOVEFILTERS(), 'Actual Data'[Status] = "Closed" )
VAR _ClosedDate =
    IF (
            ISBLANK ( _MaxClosedDate ),
            _MinClosedDate - 1,
            _MaxClosedDate
    )
RETURN
    CALCULATE (
        COUNT ( 'Actual Data'[CaseID] ),
        REMOVEFILTERS(),
        'Actual Data'[Status] = "Closed",
        'Actual Data'[Created Date] > _ClosedDate
            && 'Actual Data'[Created Date] <= _CreatedDate
    )
 
talespin_0-1711516413184.png

 

 

Hi @talespin thanks for your valuable time. i am expecting count 2 for 2015 as we have only 2 cases active until 2015. we spend alot of time on this, i agree this is a trickier and complex one.really appreciate your vaulable time. you have very good understanding in DAX. 

hi @johnbasha33 

 

Please highlight/share screenshot where the issue is and explaining in detail what the issue is, assuming underlying data is same as in the sample pbix file which you shared earlier.

 

Hi @talespin  thanks for helping, this seems to be complicated,

here is the latest pbix file with sample data. 
https://drive.google.com/file/d/1-6crHQAZAbiD3YEKynvjdny_wlL-HhJT/view?usp=drive_link

 

this is what i am expecting to see the Dynamic cummulative count.

johnbasha33_0-1711541642008.png

and finally this is what i am expecting to see in the grapth for each created year 

johnbasha33_1-1711541673924.png

i know it is a challenging one, lets hope we can crack this one last time.

hi @johnbasha33 

 

I am not able to understand the requirement.

 

For row5 in your screenshot the count starts from 2.

For row8 YEAR(Created Date) = YEAR(Closed Date) but the count doesn't reset.

@talespin Hi, it doesnt have to reset. we are no longer considering YEAR(Created Date) = YEAR(Closed Date) this condition. even though there is YEAR(Created Date) = YEAR(Closed Date) we consider it in the active count. 
YEAR(Closed Date) should be less than YEAR(Created Date) for the count. 

Greg_Deckler
Community Champion
Community Champion

@johnbasha33 Better Running Total - Microsoft Fabric Community



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler its not a straight forward situation, pls read my question one more time. 

@johnbasha33 Without sample data and expected output it's near impossible to be specific.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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