Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hello,
My goal is to create chart like this - that it always has selection from calendar slicer in one bar, and end of year, so December of previous year and 2 years back (from year of selection)
I'd be grateful for any help
Solved! Go to Solution.
Hi @Pbiuserr ,
First create a calendar table in the model, like this:
then please create measures:
Select month sales =
SUM('Table'[Value])
Sales in December of year-1 =
VAR _selectvalue = SELECTEDVALUE('Calendar'[Month-Year])
VAR _date = CALCULATE(MAX('Calendar'[Date]),FILTER('Calendar','Calendar'[Month-Year]=_selectvalue))
VAR _year = YEAR(_date)
VAR _result = CALCULATE(SUM('Table'[Value]),FILTER(ALL('Calendar'),'Calendar'[Year]=_year-1&&'Calendar'[Month]=12))
RETURN
_result
Sales in December of year-2 =
VAR _selectvalue = SELECTEDVALUE('Calendar'[Month-Year])
VAR _date = CALCULATE(MAX('Calendar'[Date]),FILTER('Calendar','Calendar'[Month-Year]=_selectvalue))
VAR _year = YEAR(_date)
VAR _result = CALCULATE(SUM('Table'[Value]),FILTER(ALL('Calendar'),'Calendar'[Year]=_year-2&&'Calendar'[Month]=12))
RETURN
_result
The PBIX file is attached for reference.
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
Hi @Pbiuserr ,
First create a calendar table in the model, like this:
then please create measures:
Select month sales =
SUM('Table'[Value])
Sales in December of year-1 =
VAR _selectvalue = SELECTEDVALUE('Calendar'[Month-Year])
VAR _date = CALCULATE(MAX('Calendar'[Date]),FILTER('Calendar','Calendar'[Month-Year]=_selectvalue))
VAR _year = YEAR(_date)
VAR _result = CALCULATE(SUM('Table'[Value]),FILTER(ALL('Calendar'),'Calendar'[Year]=_year-1&&'Calendar'[Month]=12))
RETURN
_result
Sales in December of year-2 =
VAR _selectvalue = SELECTEDVALUE('Calendar'[Month-Year])
VAR _date = CALCULATE(MAX('Calendar'[Date]),FILTER('Calendar','Calendar'[Month-Year]=_selectvalue))
VAR _year = YEAR(_date)
VAR _result = CALCULATE(SUM('Table'[Value]),FILTER(ALL('Calendar'),'Calendar'[Year]=_year-2&&'Calendar'[Month]=12))
RETURN
_result
The PBIX file is attached for reference.
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
108 | |
108 | |
107 | |
89 | |
61 |
User | Count |
---|---|
171 | |
139 | |
133 | |
103 | |
86 |