Forum Discussion
Creating a Measure Between Two Unrelated Tables
- Anonymous1 year ago
Hi duisinvalid ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) We can create measures.
Measure = var _all_day=COUNTROWS(ALLSELECTED('Date'[Date])) var _day_a=_all_day-COUNTROWS(FILTER(ALL('Table b'),[Day_Unopen]<=MAX('Date'[Date]) && [Day_Unopen]>=MIN('Date'[Date]) && [Factory]="A")) var _day_b=_all_day-COUNTROWS(FILTER(ALL('Table b'),[Day_Unopen]<=MAX('Date'[Date]) && [Day_Unopen]>=MIN('Date'[Date]) && [Factory]="B")) var _pop_a=CALCULATE(SUM('Table a'[Population]),FILTER(ALL('Table a'),[Machine_Type]=MAX('Table a'[Machine_Type]) && [Factory]="A")) var _pop_b=CALCULATE(SUM('Table a'[Population]),FILTER(ALL('Table a'),[Machine_Type]=MAX('Table a'[Machine_Type]) && [Factory]="B")) RETURN _day_a*_pop_a*24 + _day_b*_pop_b*24Measure 2 = SUMX(VALUES('Table a'[Machine_Type]),[Measure])(3) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi duisinvalid - you can create a measure in Power BI that calculates the total running hours for each machine type
similar solved threads FYR:
Solved: Calculate total hours worked from multiple check i... - Microsoft Fabric Community
Time Calculation Summing Work Hours - Power BI - Enterprise DNA Forum
Modify the table name as per your model:
Total Running Hours =
VAR TotalDaysOpen =
COUNTROWS(
FILTER(
ALL('Factory'),
'Factory'[Day_Unopen] >= MIN('Date'[Date]) &&
'Factory'[Day_Unopen] <= MAX('Date'[Date])
)
)
VAR HoursPerDay = 24
VAR PopulationFactor = SUMX(
'MachineTable',
'MachineTable'[Population] * HoursPerDay
)
RETURN
TotalDaysOpen * PopulationFactor
To make sure the formula works dynamically with a date slicer, you will need to ensure that the date table is correctly linked to the factories and machines.
Hope the above logic helps.
thanks for the reply! I gave it a try but this solution didn't sectionalize the factories and multiply it by the weight of the population of a given machine in a specific factory.
I will keep working on it, but if you think that there's a way to get it's total hours that would be awesome.