Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
mandeld
Frequent Visitor

!!PLEASE HELP CONVERTING SQL TO DAX!!

Good Afternoon PBI users, 

 

I am looking to convert this query into a dax code:

SELECT sum(cost) 
FROM TBL1
INNER JOIN TBL2 ON TBL1.ID= TBL2.ID
WHERE TBL1.Date1 BETWEEN '10/01/2022' AND '12/31/2022'
AND TBL2.Date2 BETWEEN '10/01/2022' AND '12/31/2022'

 

In PBI there I have a Table(containing these two dates), both connected to a Date table. I want to take the 'sum of Cost' and make sure my date "slicer"  mandeld_0-1677001137163.png is filtering for both dates. This is what I thought of but it is not quite right. PLEASE HELP!!!

 

TEST =

CALCULATE (
        CALCULATE ( SUM ( Table[Cost]),
        USERELATIONSHIP (Date[Date],Table[Date1])),
        USERELATIONSHIP (Date[Date],Table[Date2])
)
1 ACCEPTED SOLUTION
mandeld
Frequent Visitor

Here is the solution in case this helps anyone else!
 
TEST = CALCULATE(SUM(Table[cost]),
DATESBETWEEN(Table[Date1],min(Date[Date]),max(Date[Date])),
USERELATIONSHIP(Table[Date2],Date[Date]))

View solution in original post

1 REPLY 1
mandeld
Frequent Visitor

Here is the solution in case this helps anyone else!
 
TEST = CALCULATE(SUM(Table[cost]),
DATESBETWEEN(Table[Date1],min(Date[Date]),max(Date[Date])),
USERELATIONSHIP(Table[Date2],Date[Date]))

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.