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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
njxfoster
Helper I
Helper I

Calculate date base on date row and create duplicates

Hi guys

 

njxfoster_0-1707433336832.png

 

I want to create duplicate row which show duration of a event.

 

For example, "SetupsStart"=1/26    "AgentsAll In" =1/30

 

I want to create extra rows which cover the period which the result will come out as

 

SetupsStart1/26/2024
SetupsStart1/27/2024
SetupsStart1/28/2024
SetupsStart1/29/2024
AgentsAll In1/30/2024

 

Is there anyway to achieve this ?

 

Thanks in advances!!!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @njxfoster 

 

I have provided a way to solve your problem:

 

Here's some dummy data

 

"Table"

vnuocmsft_0-1707456632688.png

 

You can create a new date table with the time range "01/26/2024" to "01/30/2024".

 

vnuocmsft_2-1707456873077.png

 

Date = CALENDAR("1/26/2024", "1/30/2024")

 

vnuocmsft_1-1707456741805.png

 

Create a measure. Determine the date range and fill in the value.

Event = 
var start_date = 
    CALCULATE(
        MAX('Table'[Date]), 
        FILTER(
            ALL('Table'), 
            'Table'[Event] = "SetupsStart"
        )
    )
var end_date = 
    CALCULATE(
        MIN('Table'[Date]), 
        FILTER(
            ALL('Table'), 
            'Table'[Event] = "AgentsALL In"
        )
    )
RETURN 
    IF(
        SELECTEDVALUE('Date'[Date]) >= start_date 
        && 
        SELECTEDVALUE('Date'[Date]) <> end_date, 
        "SetupsStart", 
        "AgentsALL In"
    )

 

Here is the result.

 

vnuocmsft_3-1707457095856.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @njxfoster 

 

I have provided a way to solve your problem:

 

Here's some dummy data

 

"Table"

vnuocmsft_0-1707456632688.png

 

You can create a new date table with the time range "01/26/2024" to "01/30/2024".

 

vnuocmsft_2-1707456873077.png

 

Date = CALENDAR("1/26/2024", "1/30/2024")

 

vnuocmsft_1-1707456741805.png

 

Create a measure. Determine the date range and fill in the value.

Event = 
var start_date = 
    CALCULATE(
        MAX('Table'[Date]), 
        FILTER(
            ALL('Table'), 
            'Table'[Event] = "SetupsStart"
        )
    )
var end_date = 
    CALCULATE(
        MIN('Table'[Date]), 
        FILTER(
            ALL('Table'), 
            'Table'[Event] = "AgentsALL In"
        )
    )
RETURN 
    IF(
        SELECTEDVALUE('Date'[Date]) >= start_date 
        && 
        SELECTEDVALUE('Date'[Date]) <> end_date, 
        "SetupsStart", 
        "AgentsALL In"
    )

 

Here is the result.

 

vnuocmsft_3-1707457095856.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Hi Thank you for your reply! I need a solution that can cover all these event. The solution you provided only cover "SetupStart"and "AgentsAll in". Is there a solution that can cover all the other events (eg LeapStat, PrepStart etc) as well as other events that get added in the future?

lbendlin
Super User
Super User

Once you have that, what will be your next step?  Some sort of count of days per event?

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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