The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello.
I have a table in which I use some measures to realize the total, difference and variation between two years. When using DAX measures the annuities passed them as a fixed value in each of the calculations, I would like to be able to select the year for one column and independently the year for another and perform the calculations.
I put a screenshot and try to explain myself better:
In this table where you put Total19 and Total20, I calculate them as follows:
All the data I have in the same table, I have an annuity field, I also have in that table a date field (DDMMAAAA).
Solved! Go to Solution.
You must extract the year column as a seprate table:
Year table = DISTINCT('Table'[Year])
Create measures like this:
Total1 = SUM('Table'[value])
Total2 =
CALCULATE (
SUM ( 'Table'[value] ),
FILTER (
ALL ( 'Table' ),
'Table'[Year] = SELECTEDVALUE ( 'Year table'[Year] )
&& 'Table'[Category] IN DISTINCT ( 'Table'[Category] )
)
)
Diff = [Total2] - [Total1]
Attached to a sample file in the following, you hope it could help.
Best regards
Community Support Team _ Yingjie Li
If this post helps,then consider Accepting it as the solution to help other members find it faster.
Fixed I created one more line in the filter and it already does what I need.
Greetings.
You must extract the year column as a seprate table:
Year table = DISTINCT('Table'[Year])
Create measures like this:
Total1 = SUM('Table'[value])
Total2 =
CALCULATE (
SUM ( 'Table'[value] ),
FILTER (
ALL ( 'Table' ),
'Table'[Year] = SELECTEDVALUE ( 'Year table'[Year] )
&& 'Table'[Category] IN DISTINCT ( 'Table'[Category] )
)
)
Diff = [Total2] - [Total1]
Attached to a sample file in the following, you hope it could help.
Best regards
Community Support Team _ Yingjie Li
If this post helps,then consider Accepting it as the solution to help other members find it faster.
Hello, this served me, starting from your example I have a problem, I need you to filter through a city field, total1 does it correctly, but the total2 does not, the city is the same for the two totals, would you have to add another filter in the formula?
Fixed I created one more line in the filter and it already does what I need.
Greetings.
Hello, thank you very much for the solution, as that is what I need, it is giving me problems the data that shows me, but it is a matter of reviewing the example that you have provided me.
Greetings.
@Syndicate_Admin , not very clear. refer this blog does it for two date ranges. Seem like you need for two years
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601
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 August 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
80 | |
71 | |
51 | |
50 |
User | Count |
---|---|
128 | |
122 | |
77 | |
64 | |
60 |