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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
REL
New Member

Number of days w/i qtrs for a period of time

I have a table of events with a start date and end date for each event. The start end and dates don't necessarily coincide with the start or end of months,quarters or years. I need to create a report with the event and the number of days, by year/qtr for the period of the event. I can use DateDiff to get the totals number of days or quarters between the start and end dates, but havent seen how to get the number of days, by qtr for the start to end date of the event.

 

Bob

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You can get the number of days in a period by creating a new measure

Event days =
VAR StartDate =
    SELECTEDVALUE ( 'Events'[Start Date] )
VAR EndDate =
    SELECTEDVALUE ( 'Events'[End Date] )
VAR Result =
    CALCULATE (
        COUNTROWS ( 'Date' ),
        KEEPFILTERS ( DATESBETWEEN ( 'Date'[Date], StartDate, EndDate ) )
    )
RETURN
    Result

Put that in a matrix with your events and any column from the date table.

View solution in original post

3 REPLIES 3
johnt75
Super User
Super User

You can get the number of days in a period by creating a new measure

Event days =
VAR StartDate =
    SELECTEDVALUE ( 'Events'[Start Date] )
VAR EndDate =
    SELECTEDVALUE ( 'Events'[End Date] )
VAR Result =
    CALCULATE (
        COUNTROWS ( 'Date' ),
        KEEPFILTERS ( DATESBETWEEN ( 'Date'[Date], StartDate, EndDate ) )
    )
RETURN
    Result

Put that in a matrix with your events and any column from the date table.

That did it. Thanks

lbendlin
Super User
Super User

You use INTERSECT() for that.

 

If you like more help please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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