Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello ladies and gents,
This is killing me. I have an Amount for each month of the previous two years. I want to calculate the difference between one month and the previously SELECTED month.
Like say the user selects January 2021 and January 2020. The difference should be between these months.
But if the user selects January and February 2021, the difference should be between them.
If the user selects January and June 2021, you guessed it, the difference should be between them.
I know we have PREVIOUSMONTH and SAMEPERIODLAST YEAR. But is there a way to mix them?
Huge thanks,
Alice
Solved! Go to Solution.
Hi Alice,
I may be misunderstanding, but doesn't SAMEPERIODLASTYEAR do this by itself?
When you say...
Does that mean if the user selects January and June 2021, you want to compare it with January and June 2020?
Like I say, I may be misunderstanding, but I've attached a sample PBIX in case it helps.
Gif below demonstrates what I mean.
Have I solved your problem? Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;). |
If you found this post helpful, please give Kudos. It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen. If you find my signature vaguely amusing, please give Kudos. | Proud to be a Super User! |
Hi @AliceW ,
Maybe I understand,Please try this measure and refer to the attached pbix.
diff =
VAR month_1 =
CALCULATE (
TOPN ( 1, VALUES ( 'Table'[year_month] ), 'Table'[year_month], ASC ),
ALLSELECTED ( 'Table' )
)
VAR month_2 =
CALCULATE (
TOPN ( 1, VALUES ( 'Table'[year_month] ), 'Table'[year_month], DESC ),
ALLSELECTED ( 'Table' )
)
VAR First_ =
CALCULATE (
SUM ( 'Table'[value] ),
FILTER ( 'Table', 'Table'[year_month] = month_1 )
)
VAR Second_ =
CALCULATE (
SUM ( 'Table'[value] ),
FILTER ( 'Table', 'Table'[year_month] = month_2 )
)
RETURN
Second_-First_
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you so much, guys!!
Hi @AliceW ,
Maybe I understand,Please try this measure and refer to the attached pbix.
diff =
VAR month_1 =
CALCULATE (
TOPN ( 1, VALUES ( 'Table'[year_month] ), 'Table'[year_month], ASC ),
ALLSELECTED ( 'Table' )
)
VAR month_2 =
CALCULATE (
TOPN ( 1, VALUES ( 'Table'[year_month] ), 'Table'[year_month], DESC ),
ALLSELECTED ( 'Table' )
)
VAR First_ =
CALCULATE (
SUM ( 'Table'[value] ),
FILTER ( 'Table', 'Table'[year_month] = month_1 )
)
VAR Second_ =
CALCULATE (
SUM ( 'Table'[value] ),
FILTER ( 'Table', 'Table'[year_month] = month_2 )
)
RETURN
Second_-First_
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Alice,
I may be misunderstanding, but doesn't SAMEPERIODLASTYEAR do this by itself?
When you say...
Does that mean if the user selects January and June 2021, you want to compare it with January and June 2020?
Like I say, I may be misunderstanding, but I've attached a sample PBIX in case it helps.
Gif below demonstrates what I mean.
Have I solved your problem? Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;). |
If you found this post helpful, please give Kudos. It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen. If you find my signature vaguely amusing, please give Kudos. | Proud to be a Super User! |
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
82 | |
66 | |
58 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |