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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
AnirbanMahajan
Regular Visitor

Need count of live projects as per dates

I am struggling with DAX command for generating a line graph where I need total number of live projects as per dates.

 

My table is as below:

AnirbanMahajan_2-1734507160285.png

 

I need a graph like this below:

AnirbanMahajan_1-1734506895912.png

 

Now, I need help on DAX where,

I should get 4 live WO if I select the range from 01 Jan 2024 to 31 Dec 2024 or

if I select the range from 01 Jan 24 to 31 Mar 24 then I should get 1 live WO or

if I selcet the range from 01 Jun 25 to 31 Aug 25 then I should get 1 live WO.

 

Thanks in advance

 

8 REPLIES 8
AnirbanMahajan
Regular Visitor

I need cumulative of all live projects at that point of time.

Bibiano_Geraldo
Resident Rockstar
Resident Rockstar

Hi @AnirbanMahajan ,
Please create a new measure using this DAX code:

LiveWorkOrders = 
VAR SelectedStartDate = MIN(_DateDim[FullDateAlternateKey])
VAR SelectedEndDate = MAX(_DateDim[FullDateAlternateKey])
RETURN
CALCULATE(
    COUNTROWS('WorkOrders'),
    'WorkOrders'[Start Date] <= SelectedEndDate,
    'WorkOrders'[End Date] >= SelectedStartDate
)

 You can use this measure in your line graph to display the number of live work orders over time.

I hope this helps! 
If you found this answer helpful:
✔️ Mark it as the solution to help others find it faster.
 Give it a like to show your appreciation!

Thank you for contributing to our amazing Power BI community! 

It is not working. I need DAX which would calculate all the WO which are active before the selected date and end after the selected date.

 

Eg. if

WO-1 start date is 01-Jul-24 and end date is 31-Dec-24

WO -2 start date is 01-Jan-24 and end date is 31-Dec-24

WO-3 start date is 01-Dec-24 and end date is 31-Jan-25

 

Then,

on 01-Jan-24 I should get live number as 1

on 01-Jul-24 I should get live number as 2

on 01-Dec-24 I should get live number as 3

dharmendars007
Memorable Member
Memorable Member

Hello @AnirbanMahajan , 

 

Use the following DAX measure to determine the count of live Work Orders, make sure you have Date table in place.

Live Work Orders =
VAR SelectedStart = MIN('Date'[Date])
VAR SelectedEnd = MAX('Date'[Date])
RETURN
CALCULATE(
COUNTROWS('TableName'),
'TableName'[Start Date] <= SelectedEnd &&
'TableName'[End Date] >= SelectedStart)

 

If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes 👍 are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

No, it is not working. It is not taking the count of all previous dates.

danextian
Super User
Super User

Hi @AnirbanMahajan 

 

You will need something like this:

Contracts by Time Period = 
VAR StartDate =
    MIN ( Dates[Date] )
VAR EndDate =
    MAX ( Dates[Date] )
RETURN
    COUNTROWS (
        FILTER (
            Contracts,
            Contracts[Date Start] <= EndDate
                && Contracts[Date End] >= StartDate
                && Contracts[Paid Fee] = "Yes"
        )
    )

The min and max dates are from an unrelated table.

Please see the attached pbix for details.










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

No, it is not working. It is not taking the count of all previous dates.

Hi @AnirbanMahajan 

If you want the sum of all dates, the calculation must be evaluated for each date and then summed up. Here's the updated formula.

Contracts by Time Period =
VAR StartDate =
    MIN ( Dates[Date] )
VAR EndDate =
    MAX ( Dates[Date] )
RETURN
    SUMX (
        VALUES ( Dates[Date] ),
        COUNTROWS (
            FILTER (
                Contracts,
                Contracts[Date Start] <= EndDate
                    && Contracts[Date End] >= StartDate
                    && Contracts[Paid Fee] = "Yes"
            )
        )
    )

 If this doesnt work, please provide a workable sample data (not an image) and your expected result from that.










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.