This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hi
I am trying to create a dax measure, where if the date (taken from the date table) is between the start and end date then sum the cost.
I'm think i'm trying to combine too many steps in one. Is someone able to help with the query?
Thanks
| Cost | Start Date | End date |
| 10 | 01/01/2024 | 05/01/2024 |
| 20 | 08/01/2024 | 09/01/2024 |
| 20 | 10/01/2024 | 15/01/2024 |
| Date table |
| 01/01/2024 |
| 02/01/2024 |
| 03/01/2024 |
| 04/01/2024 |
| 05/01/2024 |
| 06/01/2024 |
| 07/01/2024 |
| 08/01/2024 |
Solved! Go to Solution.
Hi @Anonymous ,
Your solution is great, bhanu_gautam. It worked like a charm! Here I have another idea in mind, and I would like to share it for reference.
I create two tables as you mentioned.
Then I create a calculated column and here is the DAX code.
Column =
SUMX(
'Table',
IF(
'Date'[Date] >= 'Table'[Start Date] && 'Date'[Date] <= 'Table'[End Date],
'Table'[Cost],
0
)
)
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Your solution is great, bhanu_gautam. It worked like a charm! Here I have another idea in mind, and I would like to share it for reference.
I create two tables as you mentioned.
Then I create a calculated column and here is the DAX code.
Column =
SUMX(
'Table',
IF(
'Date'[Date] >= 'Table'[Start Date] && 'Date'[Date] <= 'Table'[End Date],
'Table'[Cost],
0
)
)
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous , You can try below DAX for this
DAX
TotalCost :=
VAR SelectedDate = SELECTEDVALUE('DateTable'[Date])
RETURN
SUMX(
FILTER(
'CostTable',
SelectedDate >= 'CostTable'[Start Date] && SelectedDate <= 'CostTable'[End Date]
),
'CostTable'[Cost]
)
Proud to be a Super User! |
|
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 28 | |
| 28 | |
| 26 | |
| 20 | |
| 16 |
| User | Count |
|---|---|
| 52 | |
| 49 | |
| 39 | |
| 20 | |
| 20 |