cancel
Showing results 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

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.

 Item Start date End date Production time A 12.1.2020 14.2.2022 7 A 14.2.2022 15.5.2023 7,2 A 15.5.2023 15.5.2030 7,3 B 30.5.2011 30.5.2020 6 B 30.5.2020 29.6.2030 5,9

2) second table

 Item Date Quantity A 25.5.2021 3 A 14.3.2022 6 A 16.8.2023 1 B 21.8.2023 2

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
Super User

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.

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.

This will give below output,

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
Drop an email at crm@inogic.com
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/
2 REPLIES 2
Super User

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.

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.

This will give below output,

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
Drop an email at crm@inogic.com
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/
Frequent Visitor

Thank you!

Announcements

#### 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.

#### Power BI Monthly Update - August 2024

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

#### Microsoft Fabric & AI Learning Hackathon

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

#### Fabric Community Update - August 2024

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

Top Solution Authors
Top Kudoed Authors