The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Profit PY = CALCULATE( FS[Profit],SAMEPERIODLASTYEAR(DimTime[Date].[Date]),FILTER(ALL(DimTime[Date].[Date]),DimTime[Date].[Date] >= [Start of Previous Period] && DimTime[Date].[Date] <= Today())
) - I'm having issues with my DAX
I am trying to get the profit of Prior Year to show on a combo chart that is filtered by a slicer.
2 Main issues:
- The PY profit line extends into the next year and I would like it to be cut off by today.
- When the slicer does not include the previous year, the measure does not account for the data and therefore ignores it.
Hi @Skorcamp ,
I think ALL function in your code will make your result incorrect. Make sure you have created a relationship between DimDate table and FS table. Then use SAMEPERIODLASTYEAR function directly.
Profit PY = CALCULATE([Profit],SAMEPERIODLASTYEAR(DimDate[Date]))
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Rico,
I really appreciate your assistance. I have used multiple variations of the formula I provided as well as the one you suggested. To give more details from the example you have.
As profit shows 2020, 2021 and some of 2022. As the slicer has filtered out the remaining data. I would like the PY profit to show 2019, 2020 and some of 2021 throughout the entire range of the chart in your example and it would be perfect.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
102 | |
97 | |
80 | |
62 | |
57 |
User | Count |
---|---|
261 | |
120 | |
113 | |
83 | |
71 |