Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello,
I am involved in a simple problem and I am not able to solve that.
I need the SUM function would be filtered by a measure that contains a date, but It doesn't work.
The function is:
Bags YoY = CALCULATE(sum('Sales & Returns'[(*) Sale quantity (bags)]),filter('Sales & Returns','Sales & Returns'[(*) Sales order date (adjusted)]<=[LastOrderDatePY]))
The measure that is the filter takes the last date of other data set and It works right.
LastOrderDatePY = LASTDATE('Sales orders'[(*) Sales order date])
The result of the function is blank, but If I change the main replacing the measure by the date function, It works fine:
Bags YoY = CALCULATE(sum('Sales & Returns'[(*) Sale quantity (bags)]),filter('Sales & Returns','Sales & Returns'[(*) Sales order date (adjusted)]<=DATE(2019,10,10))
But I need that the date would be updated dynamically taking the last date of the other table.
I am checked that the date format of all columns and measure involved in that have the same date format and they are right.
Could you give me a hand please?.
Thanks in advance.
Alejo
Solved! Go to Solution.
@alejopiero , try like
Bags YoY = CALCULATE(sum('Sales & Returns'[(*) Sale quantity (bags)]),filter(all('Sales & Returns'),'Sales & Returns'[(*) Sales order date (adjusted)]<=[LastOrderDatePY]))
better do with date table
Bags YoY = CALCULATE(sum('Sales & Returns'[(*) Sale quantity (bags)]),filter(all('Date'),'Date'[Date]<=LASTDATE('Date'[Date])))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
@alejopiero , try like
Bags YoY = CALCULATE(sum('Sales & Returns'[(*) Sale quantity (bags)]),filter(all('Sales & Returns'),'Sales & Returns'[(*) Sales order date (adjusted)]<=[LastOrderDatePY]))
better do with date table
Bags YoY = CALCULATE(sum('Sales & Returns'[(*) Sale quantity (bags)]),filter(all('Date'),'Date'[Date]<=LASTDATE('Date'[Date])))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
Try this
Bags YoY =
VAR _lastdate =
CALCULATE (
MAX ( 'Sales orders'[(*) Sales order date] )
)
VAR _result =
CALCULATE (
SUM ( 'Sales & Returns'[(*) Sale quantity (bags)] ),
FILTER (
'Sales & Returns',
'Sales & Returns'[(*) Sales order date (adjusted)] <= _lastdate
)
)
RETURN
_result
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
69 | |
55 | |
36 | |
31 |
User | Count |
---|---|
87 | |
62 | |
61 | |
49 | |
45 |