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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.