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
evadung
Frequent Visitor

Calculate production time*quantity

Hello, I need to calculate production time*quantity in DAX. I have two tables and calendar table.

 

1) first table with production time for each item.

ItemStart dateEnd dateProduction time
A12.1.202014.2.2022

7

A14.2.202215.5.20237,2
A15.5.202315.5.20307,3
B30.5.201130.5.20206
B30.5.202029.6.20305,9

 

2) second table

ItemDateQuantity
A25.5.20213
A14.3.20226
A16.8.20231
B21.8.20232

 

I was thinking using {Number.From([Start date])..Number.From([End date])} in Query, but I think it is pointless. Totaly have no clue how to do it easier. Thanks for any help.

1 ACCEPTED SOLUTION
SamInogic
Super User
Super User

Hi @evadung ,

It seems that you want to retreieve the Production Time in second table based on Date if it falls within start date and end date of First Table.

So, You can follow below steps to achieve your requirement.

1. Create a column in Second table with below DAX expression:

FinalCalculation =

var sampledate = 'Table Second'[Date].[Date]

var productiontime =

    CALCULATE (

       MIN('Table'[Production time]),

        FILTER (

            'Table',

            'Table'[Start date].[Date] <= sampledate

                && 'Table'[End date].[Date] >= sampledate && 'Table Second'[Item] = 'Table'[Item]

        )

    )

    return productiontime*'Table Second'[Quantity]

 

Please refer to the below screenshot for the same.

SamInogic_0-1692602590672.png

 

This will give below output,

SamInogic_1-1692602598028.png

 

Thanks!

 

Inogic Professional Services Division

Power Platform and Microsoft Dynamics 365 CRM Development – All under one roof!

Drop an email at crm@inogic.com

Services:  http://www.inogic.com/services/

Power Platform/Dynamics 365 CRM Tips and Tricks:  http://www.inogic.com/blog/

Inogic Professional Services: Power Platform/Dynamics 365 CRM
An expert technical extension for your techno-functional business needs
Drop an email at crm@inogic.com
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/

View solution in original post

2 REPLIES 2
SamInogic
Super User
Super User

Hi @evadung ,

It seems that you want to retreieve the Production Time in second table based on Date if it falls within start date and end date of First Table.

So, You can follow below steps to achieve your requirement.

1. Create a column in Second table with below DAX expression:

FinalCalculation =

var sampledate = 'Table Second'[Date].[Date]

var productiontime =

    CALCULATE (

       MIN('Table'[Production time]),

        FILTER (

            'Table',

            'Table'[Start date].[Date] <= sampledate

                && 'Table'[End date].[Date] >= sampledate && 'Table Second'[Item] = 'Table'[Item]

        )

    )

    return productiontime*'Table Second'[Quantity]

 

Please refer to the below screenshot for the same.

SamInogic_0-1692602590672.png

 

This will give below output,

SamInogic_1-1692602598028.png

 

Thanks!

 

Inogic Professional Services Division

Power Platform and Microsoft Dynamics 365 CRM Development – All under one roof!

Drop an email at crm@inogic.com

Services:  http://www.inogic.com/services/

Power Platform/Dynamics 365 CRM Tips and Tricks:  http://www.inogic.com/blog/

Inogic Professional Services: Power Platform/Dynamics 365 CRM
An expert technical extension for your techno-functional business needs
Drop an email at crm@inogic.com
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/

Thank you! 

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.

August Carousel

Fabric Community Update - August 2024

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