Forum Discussion
counting rows that are dependent from two different tables
- 9 years ago
Hi aake,
After going over the sample data provided above, I would suggest you to merge "IN" table and "OUT" table into a single table(assume it is called "Merged_IN_OUT") first, then you should be able to use the formula below to create the measure "WIP".
WIP = CALCULATE ( COUNTROWS ( Merged_IN_OUT ), FILTER ( Merged_IN_OUT, Merged_IN_OUT[Start] < MAX ( workdays[Workdate] ) && Merged_IN_OUT[Shipment] < MAX ( workdays[Workdate] ) && Merged_IN_OUT[LastStatus] = "Shipped" ) )Here is the sample pbix file for your reference.
In addition, for more details about how to use Merge Queries in Power BI Desktop, you can refer to the following articles:
POWER BI DESKTOP : MERGE QUERY OPTIONS
Shape and combine data in Power BI Desktop
Regards
Hi aake,
After going over the sample data provided above, I would suggest you to merge "IN" table and "OUT" table into a single table(assume it is called "Merged_IN_OUT") first, then you should be able to use the formula below to create the measure "WIP".
WIP =
CALCULATE (
COUNTROWS ( Merged_IN_OUT ),
FILTER (
Merged_IN_OUT,
Merged_IN_OUT[Start] < MAX ( workdays[Workdate] )
&& Merged_IN_OUT[Shipment] < MAX ( workdays[Workdate] )
&& Merged_IN_OUT[LastStatus] = "Shipped"
)
)Here is the sample pbix file for your reference.
In addition, for more details about how to use Merge Queries in Power BI Desktop, you can refer to the following articles:
POWER BI DESKTOP : MERGE QUERY OPTIONS
Shape and combine data in Power BI Desktop
Regards
Hi v-ljerr-msft
Thx for this solution,
Calculation is not ok, but you showed me how it schould look like.
What i was trying to get this:
WIP =
CALCULATE (
COUNTROWS ( Merged_IN_OUT ),
FILTER (
Merged_IN_OUT,
Merged_IN_OUT[Start] < MAX ( workdays[Workdate] )
)
) - CALCULATE (
COUNTROWS ( Merged_IN_OUT ),
FILTER (
Merged_IN_OUT,
Merged_IN_OUT[Shipment] < MAX ( workdays[Workdate] )
&& Merged_IN_OUT[LastStatus] = "Shipped"
)
)so it works pretty well :)