Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
My goal is to create a messure [Sales] that will be calculated based on the same date field.
My Tables:
Table 1: Date
Table 2: SKU Adds
Table 3: Receipts
Table 4: Invoice History
Expected Output:
Sum of Invoice amount for IDs with 'invoice date' in same period as 'Date Added'
Notes:
Sales =
CALCULATE( SUMX('Invoice History', 'Invoice History'[Unit Price] * 'Invoice History'[QTY Invoiced]),
USERELATIONSHIP('Date'[Date], 'Invoice History'[Invoice Date]) )
Sales =
CALCULATE( SUMX('Invoice History', 'Invoice History'[Unit Price] * 'Invoice History'[QTY Invoiced]),
USERELATIONSHIP('Date'[Date], 'Invoice History'[Invoice Date]),
USERELATIONSHIP('Date'[Date], 'SKU Adds'[Date Added]) )
I've also tried cross filter.
I would like to make this more dynamic. Specifically, calculate sales within 365 days of data add
- Invoice Date <= Date Added(365)
Connecting using both the 'Invoice History'[Invoice Date] and the 'SKU Adds'[Date Added] is only giving you items where the [Date Added] and [Invoice Date] are the same. This means that since the item wasn't added in 2021, there are no instances where both [Date Added] and [Invoice Date] were the same and so it won't show anything in 2020.
For the [Date Added] you should use FILTER('SKU Adds', 'SKU Adds'[Date Added] >= EARLIER('Date'[Date])) rather than using a connection.
Whole expression would be:
Sales =
CALCULATE( SUMX('Invoice History', 'Invoice History'[Unit Price] * 'Invoice History'[QTY Invoiced]),
USERELATIONSHIP('Date'[Date], 'Invoice History'[Invoice Date]),
FILTER('SKU Adds', 'SKU Adds'[Date Added] >= EARLIER('Date'[Date])) )
More generally, connections are a powerful tool but circular connections like those cause these sort of issues and it's definitely something you need to be wary of. In the same way as PBI made some of your conections inactive by default, you should avoid using all of the connections if it creates that circular shape and replace on with a filter if necessary.
Sales_1 =
VAR StartDate = MIN('SKU Adds'[Date Added])
VAR EndDate = ENDOFYEAR('SKU Adds'[Date Added])
VAR Results = CALCULATE([Sales], FILTER('Invoice History', 'Invoice History'[Invoice Date] <= EndDate && 'Invoice History'[Invoice Date] >= StartDate)
)
Return Results
Looks like this is working as intended. Any thoughts?
Thank you for your reply. I was super excited to try this.
I understand your advice fairly well and will continue to try a few other way. As is, it does not work and gives the following error:
"EARLIER/EARLIEST refers to an earlier row context which doesn't exist."
- The Earlier function doesnt prepopulate with any options.
I have never gotten earlier to work in a dax messure. I normally use it in calculated columns instead. Im thinking I need to make a summary table use ADDCOLUMNS and filter that virtual table. Any other thoughts?
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 |
|---|---|
| 98 | |
| 72 | |
| 50 | |
| 49 | |
| 42 |