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 September 15. Request your voucher.

Reply
chelvys
New Member

Finding distinct count of object under each status for a given startdate and enddate

I have a table:

Object      Status       StartDate       EndDate

Ob1               A          2018/3/3       2018/4/18

Ob1               B          2018/4/19     2018/8/30

Ob1               S          2018/9/1       2018/10/15

Ob2               S          2018/1/13     2018/3/5

Ob2               A          2018/3/6       2018/10/18

 

In the report, a date or a week or a month, or a range of dates may be selected and  the chart need to calculate and display, for the given range how many objects are avalible for each stage.

 

How do i do this?

2 ACCEPTED SOLUTIONS
AkhilAshok
Solution Sage
Solution Sage

You can do this in multiple ways. Best way to do with minimum DAX code and minimum formula engine involvment is as below:

 

1. Create a simple Date table (you can enhance it with more columns like year, month, etc if you need).

Date = CALENDAR ( MIN ( 'Table'[Start Date] ), MAX ( 'Table'[End Date] ) )

2. Create a new Fact table:

Fact = 
SELECTCOLUMNS (
    GENERATE (
        'Table',
        DATESBETWEEN ( 'Date'[Date], 'Table'[Start Date], 'Table'[End Date] )
    ),
    "Object", 'Table'[Object],
    "Status", 'Table'[Status],
    "Date", 'Date'[Date]
)

3. Create a relationship between Date[Date] & Fact[Date]

 

4. Create the measure:

Unique Object # = DISTINCTCOUNT('Fact'[Object])

5. Now you can create your chart/table, adding Fact[Status] & [Unique Object #] and keeping Date[Date] as the slicer.

 

Hope this helps.

 

View solution in original post

LivioLanzo
Solution Sage
Solution Sage

see attached file: https://1drv.ms/u/s!AiiWkkwHZChHjy2AyKpmHxnHYq2U

 


 


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


Proud to be a Datanaut!  

View solution in original post

4 REPLIES 4
chelvys
New Member

I have a table:

Object      Status       StartDate       EndDate

Ob1               A          2018/3/3       2018/4/18

Ob1               B          2018/4/19     2018/8/30

Ob1               S          2018/9/1       2018/10/15

Ob2               S          2018/1/13     2018/3/5

Ob2               A          2018/3/6       2018/10/18

 

In the report, a date or a week or a month, or a range of dates may be selected and  the chart need to calculate and display, for the given range how many objects are avalible for each stage.

 

How do i do this?

LivioLanzo
Solution Sage
Solution Sage

see attached file: https://1drv.ms/u/s!AiiWkkwHZChHjy2AyKpmHxnHYq2U

 


 


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


Proud to be a Datanaut!  

Thank you your solutions worked.

AkhilAshok
Solution Sage
Solution Sage

You can do this in multiple ways. Best way to do with minimum DAX code and minimum formula engine involvment is as below:

 

1. Create a simple Date table (you can enhance it with more columns like year, month, etc if you need).

Date = CALENDAR ( MIN ( 'Table'[Start Date] ), MAX ( 'Table'[End Date] ) )

2. Create a new Fact table:

Fact = 
SELECTCOLUMNS (
    GENERATE (
        'Table',
        DATESBETWEEN ( 'Date'[Date], 'Table'[Start Date], 'Table'[End Date] )
    ),
    "Object", 'Table'[Object],
    "Status", 'Table'[Status],
    "Date", 'Date'[Date]
)

3. Create a relationship between Date[Date] & Fact[Date]

 

4. Create the measure:

Unique Object # = DISTINCTCOUNT('Fact'[Object])

5. Now you can create your chart/table, adding Fact[Status] & [Unique Object #] and keeping Date[Date] as the slicer.

 

Hope this helps.

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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