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
BIWConsult
New Member

How to calculate # of active projects with status on each day.

Hi, 

 

I'm currently working on a project where we want to plot the number of projects in a given time frame and see how many of them have which status on each day. 

 

So lets say we have:

Project IDStatusDate
Project APending01/01/2022
Project AAccepted04/01/2022
Project AExecuted05/01/2022
Project BPending03/01/2022
Project BAccepted

04/01/2022

Project CPending

04/01/2022

 

What we want to do is track how many projects have a certain status every day.

Like this:

Date# of Pending# of Accepted# of Executed
01/01/20221 (A)00
02/01/20221 (A)00
03/01/20222 (A+B)00
04/01/20221 (C)2 (A+B)0
05/01/20221 (C)1 (B)

1 (A)

 

Any ideas on how we could achieve this?

This is how we currently tried to calculate this, the problem is that the cumulative keeps going, even if the status of a project changes.

BIWConsult_2-1662305322057.png

 

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1662318773418.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

5 REPLIES 5
tamerj1
Super User
Super User

Hi @BIWConsult 
Actually I had a 2nd look at your request and I thought there is another option to do this which is using a mtrix visual instead of a table. You can have a disconnected table containing all unique status value and use it in the columns of the matix along with the only one measure (instead of three measures) as follows

1.png2.png

Count = 
VAR CurrentDate = 
    MAX ( 'Date'[Date] )
VAR CurrentStatus =
    SELECTEDVALUE ( 'Status'[Status] )
VAR CurrentProjects = 
    CALCULATETABLE ( 
        VALUES ( Data[Project ID] ), 
        ALL ( 'Date' ),
        'Date'[Date] <= CurrentDate 
    )
VAR SelectedProjects =
    FILTER ( 
        CurrentProjects,
        VAR CurrentData = CALCULATETABLE ( Data, ALL ( 'Date' ), 'Date'[Date] <= CurrentDate )
        VAR LastRecord = TOPN ( 1, CurrentData, Data[Date] )
        VAR LastStatus = MAXX ( LastRecord, Data[Status] )
        RETURN
            LastStatus = CurrentStatus
    )
RETURN
    COUNTROWS ( SelectedProjects )
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1662318773418.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

tamerj1
Super User
Super User

Hi @BIWConsult 

Please refer to attached sample file.

I assume you have an active relationship between your projects table and the date table which you don't have any intention to remove it.

The "CurrentProjects" is just an optimization to reduce the number of unnecessary iterations.

2.png1.png

# of Accepted = 
VAR CurrentDate = 
    MAX ( 'Date'[Date] )
VAR CurrentProjects = 
    CALCULATETABLE ( 
        VALUES ( Data[Project ID] ), 
        ALL ( 'Date' ),
        'Date'[Date] <= CurrentDate 
    )
VAR AcceptedProjects =
    FILTER ( 
        CurrentProjects,
        VAR CurrentData = CALCULATETABLE ( Data, ALL ( 'Date' ), 'Data'[Date] <= CurrentDate )
        VAR LastRecord = TOPN( 1, CurrentData, Data[Date] )
        VAR LastStatus = MAXX ( LastRecord, Data[Status] )
        RETURN
            LastStatus = "Accepted"
    )
RETURN
    COUNTROWS ( AcceptedProjects )
Greg_Deckler
Community Champion
Community Champion

@BIWConsult So why not create a Matrix visual with Date as rows, Status as Columns and a distinct count of Project ID as values?



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

Hi Greg,

 

The problem is the client wants it in a column chart like this, in order to make the evolution more visible.

BIWConsult_0-1662311967822.png

 

Kind regards

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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