Forum Discussion

johnbasha33's avatar
johnbasha33
Super User
2 years ago
Solved

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? 

 

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 

  • talespin's avatar
    talespin
    2 years ago

    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)
     

     

     

20 Replies

    • johnbasha33's avatar
      johnbasha33
      Super User

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

      • Anonymous's avatar
        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

  • talespin's avatar
    talespin
    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's avatar
        talespin
        Solution Sage

        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)