Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Pbiuserr
Post Prodigy
Post Prodigy

How to create chart, axis like this

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)

 

Pbiuserr_1-1657564179018.png

 

I'd be grateful for any help

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @Pbiuserr ,

 

First create a calendar table in the model, like this:

vcgaomsft_0-1657767802616.png

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

vcgaomsft_1-1657767930147.png

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

View solution in original post

1 REPLY 1
v-cgao-msft
Community Support
Community Support

Hi @Pbiuserr ,

 

First create a calendar table in the model, like this:

vcgaomsft_0-1657767802616.png

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

vcgaomsft_1-1657767930147.png

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.