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
amaoa
Helper II
Helper II

Ontrack DAX Expression

Hello All,

So I wrote the DAX expressions for the different task status count by date. But my Ontrack expression is not all inclusive or not capturing all the different counts of tasks status dates for Ontrack tasks. See below expressions I wrote for all the different Status (complete, late, not started & ontrack) counts. My Ontrack is missing some scenarios or conditions and I can't wrap my head around which or how to make my expression all inclusive. The sample data used that is not showing correctly is shown below. The first image shows 16 ontrack tasks but my expression displays only 15 counts. The second image shows 21, but my expression displays only 20 counts. I will appreciate any insight or feedback into the correct DAX expression that captures all the different scenarios that shows the correct counts.

 

Complete: TaskPercent Completed = 100%.  Easiest of all.

Late = SUMX(Tasks, IF (AND(AND(TaskFinishDate < TODAY(), TaskPercentComplete<> 100), TaskFinishDate <> BLANK()), 1,0)

or = SUMX(Tasks, IF (AND(TaskStartDate < TODAY (), TaskFinishDate< TODAY()), 1,0)

Not Started = SUMX(Tasks, IF (AND (AND (TaskStartDate< TODAY (), TaskPercentComplete = 0), TaskFinishDate> TODAY()), 1,0)

Ontrack = SUMX(Tasks, IF(OR(AND(TaskStartDate<TODAY(), TaskPercentComplete>0), TaskFinishDate>TODAY()), IF (AND(TaskStartDate>TODAY(), TaskFinishDate>TODAY()), 1,0)

 

image1image1  image 2image 2

1 ACCEPTED SOLUTION

I added more details to my original question. I guess I was not clear enough.

I already have a column that shows status as shown in the two images. I just need to count how many task is Ontrack. I tried writing an expression based on the dates and % comp, but I guess I could have just written a new measure to count the Status of "Ontrack" tasks instead of trying to use the dates and % comp columns. Thanks

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@amaoa , The definition of not started and Late has overlap with on time.

 

Try if this can work, new column

switch (True(),
[TaskPercentComplete] = 1 , "Complete",
TaskStartDate<TODAY() && TaskPercentComplete>0 && TaskFinishDate>TODAY() , "Ontime",
AND(TaskStartDate>TODAY(), TaskFinishDate>TODAY()) , "Not Started",
"Late"
)

 

New column for count of Ontime

switch (True(),
[TaskPercentComplete] = 1 , 0,
TaskStartDate<TODAY() && TaskPercentComplete>0 && TaskFinishDate>TODAY() , 1,
0
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I added more details to my original question. I guess I was not clear enough.

I already have a column that shows status as shown in the two images. I just need to count how many task is Ontrack. I tried writing an expression based on the dates and % comp, but I guess I could have just written a new measure to count the Status of "Ontrack" tasks instead of trying to use the dates and % comp columns. Thanks

Greg_Deckler
Community Champion
Community Champion

@amaoa - Would need to understand the rules for On Track. But, often moving to a SWITCH(TRUE()...) statement helps clean up the logic:

Ontrack = 
  SWITCH(TRUE(),
    TaskStartDate<TODAY() && TaskPercentComplete>0,"On Track",
    TaskFinishDate>TODAY(),"On Track",
    TaskStartDate>TODAY() && TaskFinishDate>TODAY(),"On Track",
    "Not on track"
  )


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...

I am trying to count the number of tasks in the images that are ontrack. Not sure if this will help. Below is the full expression. I left some parts out in the original post. 

Ontrack = SUM(Tasks, IF....... , 1,0)))

 

Thanks

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.