Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
My file has 5 filters. I used the "dateadd" function to calculate the LY's sales (
Hi @aashoe
Maybe you can use filter instead of Time intelligence functions, just as follow:
Total Sales LY =
CALCULATE (
[Total Sales],
ALLSELECTED ( 'Sales' ),
Sales[Day] < TODAY ()
&& Sales[Day]
>= DATE ( YEAR ( Sales[Day] ) - 1, MONTH ( Sales[Day] ), DAY ( Sales[Day] ) )
)
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This formula works for the filter, but the LY sales is not correctly shown. It adds up all the sales data in the table. Any way to solve it?
Hi @aashoe
Please try this:
IF (
MAX ( Sales[Day] ) < TODAY ()
&& MAX ( Sales[Day] )
>= DATE ( YEAR ( Sales[Day] ) - 1, MONTH ( Sales[Day] ), DAY ( Sales[Day] ) ),
[Total Sales]
)
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I encountered the below error.
The system only let me picked from these measures in line 5.
Hi @aashoe
I'm sorry, I misunderstood what you meant before,
Try this please:
Total Sales LY =
VAR _CurrentRowDate =
MAX ( Sales[Day] )
RETURN
CALCULATE (
[Total Sales],
ALL ( 'Sales' ),
Sales[Day]
= DATE ( YEAR ( Sales[Day] ) - 1, MONTH ( Sales[Day] ), DAY ( Sales[Day] ) )
&& Sales[Day] < TODAY ()
)
Hope this helps,
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
There’s no error showing in the calculation, but it’s still returning 0 for the LY sales. 😞
Hi @aashoe
Could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
DATEADD should usually operate on your date table, not your Sales fact table.
If you don't have a date table, you really should add one.
I created a date table (Table = CALENDAR ( DATE ( 2023, 1, 1 ), DATE ( 2024, 12, 31 ) )), and connected it with the "Day" in other tables. Yet, I still encountered the same error. Which part did I miss?
Also, I want the filter to show the date in 2024 only. But when I use the filter on this visual funtion to change it, the LY sales cannot be calculated. Is there a way to solve it? Thank you so much!
Yikes! Why do you have two bidirectional many-to-many relationships between fact tables? I can't think of a situation that should never happen.
Are you using the date table for the slicer? Does the date table contain all the dates that are in the fact tables or do either of those go back before 2023?
I currently have 5 tables: 4 fact tables and 1 date table. I removed the day link between the fact tables and maintained a many-to-many relationship using the product style name. Does that setup make sense to you?
For the slicer, I’m using the date table. The fact tables only contain sales data for September 2023 and September 2024. Should I stick with the date table for the slicer, or would it be better to use the day field from the sales table instead?
Thank you so much for your help! I’m still learning, and your guidance means a lot to me!
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 |
---|---|
76 | |
76 | |
57 | |
36 | |
34 |
User | Count |
---|---|
99 | |
56 | |
56 | |
46 | |
40 |