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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Markando
Frequent Visitor

Performance issue with SumX and Countrows

Hi everyone

 

I've got some performance issues with an sumx and countrows.


My missionTasks table contains of about 4500 rows. My goal is to calculate how many workingdays has ackumulated between [Task start date] and today in a linegraph (I use that further on in another equation). 

 

So for every day in the graph (600 days) I performe the calculation below for 4500 rows and then add the total up. So I understand why it's so slow, but it would be intresting to see if you DAX-gurus has any input on how to make this more effective

 

SUMX(MissionTasks;
CALCULATE(
COUNTROWS(Calender);
FILTER(ALL(Calender[Date]);
Calender[Date]>=MissionTasks[Task start date]&&
Calender[Date]<=MAX(Calender[Date])&&
Calender[Date]<=MissionTasks[Master_Task due date])

;

Calender[Weekday_Calender]<=5)

)

2 REPLIES 2
Anonymous
Not applicable

 

I would split this into 2 different measures and complete it like this:

Firstly create:

Date Difference Count = VAR StartDate = FIRSTDATE('Calendar'[Date])
Var EndDate = NOW()
RETURN 
CALCULATE(
    countrows('Calendar'),
    ALL('Calendar'),
    'Calendar'[Date] >= StartDate,
    'Calendar'[Date] <= EndDate,
    Calender[Weekday_Calender] <= 5
)


Then you need:

Your Measure = SUMX(
    Values('MissionTasks'[Task Start Date]),
    [Date Difference Count]
)

You may need to set a filter to ignore any Blank [Task Start Date] values in your filters.  I created a quick simple dataset and needed to do that.  If you dont, thats ok.

Greg_Deckler
Community Champion
Community Champion

Can you post some example/sample data?

 

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.