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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Vitorino
Regular Visitor

How do i add days from a measure to a date?

Hello community,

 

How can i add calculated days from  a measure  to a date?

i Have a buy date, a sell date and seller. 

I want to add for each transaction that doesn't have a sell date, the avg number of days each seller takes to sell that product, in a column that calculates the expected time to sell in days:

 

Vitorino_0-1670774006560.png

 

 

 

 

1 ACCEPTED SOLUTION
v-xiaosun-msft
Community Support
Community Support

Hi @Vitorino ,

 

According to your description, it seems that your [sell_time(days)] is a measure. Since measures themselves come with their own calculation logic, I think that you can use calculated column to return sell_time(days) to calculate the average, and then user another calculated column to return your expected output.

Since you didn't provide whole sample data, I made a sample and here are steps.

Create two columns.

 

sell_time(days) =
IF (
    'Table'[sell date] = BLANK (),
    DATEDIFF ( 'Table'[buy date], DATE ( 1899, 12, 30 ), DAY ),
    DATEDIFF ( 'Table'[buy date], 'Table'[sell date], DAY )
)

 

 

 

Expected_time_to_selldays =
IF (
    'Table'[sell date] = BLANK (),
    AVERAGEX (
        FILTER (
            'Table',
            'Table'[sell date] <> BLANK ()
                && 'Table'[seller] = EARLIER ( 'Table'[seller] )
        ),
        'Table'[sell_time(days)]
    )
)

 

Final output:

vxiaosunmsft_0-1670919592648.png

 

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ xiaosun

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

1 REPLY 1
v-xiaosun-msft
Community Support
Community Support

Hi @Vitorino ,

 

According to your description, it seems that your [sell_time(days)] is a measure. Since measures themselves come with their own calculation logic, I think that you can use calculated column to return sell_time(days) to calculate the average, and then user another calculated column to return your expected output.

Since you didn't provide whole sample data, I made a sample and here are steps.

Create two columns.

 

sell_time(days) =
IF (
    'Table'[sell date] = BLANK (),
    DATEDIFF ( 'Table'[buy date], DATE ( 1899, 12, 30 ), DAY ),
    DATEDIFF ( 'Table'[buy date], 'Table'[sell date], DAY )
)

 

 

 

Expected_time_to_selldays =
IF (
    'Table'[sell date] = BLANK (),
    AVERAGEX (
        FILTER (
            'Table',
            'Table'[sell date] <> BLANK ()
                && 'Table'[seller] = EARLIER ( 'Table'[seller] )
        ),
        'Table'[sell_time(days)]
    )
)

 

Final output:

vxiaosunmsft_0-1670919592648.png

 

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ xiaosun

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

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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