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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Rolling cumulative Count

I am trying to calculate rolling cumulative count by weekstart (from monday) having a context filter but results are not as expected, please help how to work with DAX to get accurate result. Below it the sample data

ItemInitiatedModeState
MOCK0512926910/1/2020RunFinish
MOCK0512938210/1/2020ProductionProgress
MOCK0513781710/5/2020UATProgress
MOCK0514818910/6/2020ProductionAudit
MOCK0514825110/6/2020RunFinish
MOCK0515467610/7/2020ProductionFinish
MOCK0515674510/7/2020RunProgress
MOCK0516143810/8/2020ProductionFinish
MOCK0516197110/8/2020RunProgress
MOCK0516604010/8/2020ProductionAudit
MOCK0516604110/8/2020RunFinish
MOCK0517211810/9/2020RunFinish
MOCK0517632610/12/2020ProductionProgress
MOCK0517876910/13/2020ProductionAudit
MOCK0518564610/13/2020RunFinish
MOCK0519214510/14/2020RunFinish
MOCK0519266510/14/2020ProductionFinish
MOCK0520692210/16/2020RunFinish
MOCK0521164110/19/2020ProductionProgress
MOCK0521597710/20/2020ProductionAudit
MOCK0522520710/21/2020ProductionAudit
MOCK0523134410/22/2020ProductionFinish
MOCK0523885610/23/2020ProductionFinish
MOCK0521164210/26/2020ProductionProgress
MOCK0521597910/27/2020ProductionAudit
MOCK0522529910/28/2020ProductionAudit
MOCK0523135510/29/2020ProductionFinish
MOCK0523885910/30/2020ProductionFinish

 

and I am trying to achieve

Week start (Monday)Running
Week of 10/05/20203
Week of 10/12/20205
Week of 10/19/20208
Week of 10/26/202011

 

Sinceely,

Krishna.

2 ACCEPTED SOLUTIONS

Ok @Anonymous - see if this works. It returns the data on the right side of the image. It is not affected by the slicers, just showing that it returns the same results.

edhans_0-1604077085377.png

Running Total = 
COUNTX(
    FILTER(
        'Table',
        'Table'[Mode] = "Production"
            && ('Table'[State] = "Progress" || 'Table'[State] = "Audit")
    ),
    'Table'[Item]
)

Note: you must have a date table. Grab the PBIX file I linked to above in my first post. It is updated with this new data and the measure.

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

Anonymous
Not applicable

Sorry for the delay, restriction at my end. Thanks for the help it worked well. 

View solution in original post

9 REPLIES 9
edhans
Super User
Super User

Great @Anonymous glad it worked out. I hope you don't mind but I marked my answer as the solution. I think you accidentally marked your reply as the answer vs the actual answer.

 

Any additional questions, let us know!



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
edhans
Super User
Super User

Hi @Anonymous - can you explain your expected results a bit better? Here is what I have so far:

  1. Added a Week Starting Date to my date table and it is set for Monday - Day.Monday.
  2. Added that to the table visual
  3. Added a measure that is simply COUNTROWS('Table') which counts records in each week.

edhans_0-1604071565996.png

You can see my file here. It is not yet your expected results though, so explain how you got 3 for Oct 5, but nothing for Sept 28 with your source data, as an example. In other words, where are the 2 Oct 1 amounts going? Those are before Oct 5 week starting.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

Sorry, I should have put additional details in originalpost. Ideally I am hoping to show total count of items filter by Mode is Production and State in (Progress and Audit). As per data shared for Week 10/05/2020 (start from 10/05/2020 to 10/11/2020) total items are 12 but if I apply mode and state filters it come down to 3. Imagin the three items status not changed and new items created in following weeks. So the next week would be 10/12/2020 (10/12/2020 to 10/18/2020) total open items 6 but if I apply mode and state filters it come down to 2. so till current point in time (10/12/2020 weekstart) total open items are 2(current week)+3(previous weeks, infact I have two years historical data) is 5. So samething applies to following week 10/19/2020 (10/19/2020 to 10/23/2020) total items created 5 but if i apply mode and state filter it come down to 3 . So total open items till current point in time is (3+2+3). Ideally it is rolling cumulative items from entire data set till current. Hope I explained in detailed. Sorry I forgot to add Sept 28 weekstart.

 

How are you getting 3 for Oct 5 I get 2. I want a really good explanation of how the expected results are to be calculated before I try to get the DAX right. Here I am using filters. I have set MODE to Production, and State to Audit and Progress. Only 2 records show up, not 3.

 

I would prefer you show me using some mockups in excel where you can post a screeshot, not a long paragraph I have to disect and parse, if that is possible. Just be very very clear on how you get 3 for Oct 5 week with the given data.

edhans_0-1604074469197.png

edhans_1-1604074545701.png

 

 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

My bad, yes you are right while I am applying filter I counted previous week record as well. 

Ok @Anonymous - see if this works. It returns the data on the right side of the image. It is not affected by the slicers, just showing that it returns the same results.

edhans_0-1604077085377.png

Running Total = 
COUNTX(
    FILTER(
        'Table',
        'Table'[Mode] = "Production"
            && ('Table'[State] = "Progress" || 'Table'[State] = "Audit")
    ),
    'Table'[Item]
)

Note: you must have a date table. Grab the PBIX file I linked to above in my first post. It is updated with this new data and the measure.

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

I was restricted to copy the workbook, can please share screen captures so I can refer. I was able to create date table.

 

What do you mean you are restricted? I just checked. It opens fine. You should see this - just click download. It is a PBIX Power BI file, not a workbook.

edhans_0-1604097718846.png

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

Sorry for the delay, restriction at my end. Thanks for the help it worked well. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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