Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi,
I have a two tables like below.
I need to calculate Total Costs for every Project. (hours spent * hourly cost)
To do that I have to match these tables by multiple columns (Project ID + execution date must be between 'date from' and 'date to').
The second part (dates matching) is the main issue for me.
I tried usind TREATAS function, but I don't know how to include condition with the dates.
The solutions must be in DAX.
I attach the sample pbix file:
https://drive.google.com/file/d/17Ik6TosY5m1lLQ_MmLJSOcwevJGmJ3Sr/view?usp=sharing
Any help would be much appreciated!
Do you have another solution where there are more than 1 row per project in costs for any given date?
What additional criteria would you use to determine which row to use ?
You can use
Total Costs = SUMX(
'TimeSpent',
VAR CurrentProject = 'TimeSpent'[Project ID]
VAR HoursSpent = 'TimeSpent'[Hours Spent]
VAR CurrentDate = 'TimeSpent'[Execution date]
VAR HourlyCost =
SELECTCOLUMNS(
FILTER(
'Costs',
'Costs'[Project ID] = CurrentProject
&& 'Costs'[Date from] <= CurrentDate
&& 'Costs'[Date to] >= CurrentDate
),
"@value", 'Costs'[Hourly Cost]
)
RETURN
HourlyCost * HoursSpent
)
as long as you only have 1 row per project in costs for any given date
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 58 | |
| 45 | |
| 40 | |
| 21 | |
| 18 |