cancel
Showing results for
Did you mean:

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.

Frequent Visitor

## How to Show Previous Years' Annual Total and Current Year Year to Date Total in One Column Chart

I am trying to create a column chart that can show all preious years' annual total gross profits and current year year to date total gross profit, when a year and/or a month end date is selected from the filter panel. Is it possible? If not, 2 separate column charts work as well. Please visit the link to download the file. Thank you very much! https://www.dropbox.com/t/GXPnp2SXwDa22DHM

1 ACCEPTED SOLUTION
Super User

@InfiniteSheldon , if you select a month or a year, and you want to show more than that you need slicer on an independent date table.

example measure

//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = eomonth(_max, -60) +1
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

3 REPLIES 3
Frequent Visitor

Thank you both so much! @v-cazheng-msft @amitchandak

Community Support

You may try these two measures.

``````current year year to date total gross profit =
CALCULATE (
SUM ( 'Gross Profit'[Gross Profit] ),
FILTER (
ALL ( 'Gross Profit' ),
'Gross Profit'[Month End Date] <= MAX ( 'Date'[Month End Date] )
&& YEAR ( 'Gross Profit'[Month End Date] ) = MAX ( 'Date'[Year] )
)
)``````

``````preious years' annual total gross profits =
VAR selectedMonEndDate =
MAX ( 'Date'[Month End Date] )
VAR selectedYear =
SELECTEDVALUE ( 'Date'[Year], YEAR ( selectedMonEndDate ) )
RETURN
CALCULATE (
SUM ( 'Gross Profit'[Gross Profit] ),
FILTER (
ALL ( 'Gross Profit' ),
YEAR ( 'Gross Profit'[Month End Date] ) = ( selectedYear - 1 )
)
)``````

Then, the result looks like this.

For more details, you could refer to the attached pbix file.

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 let me know. Thanks a lot!

Best Regards,

Community Support Team _ Caiyun

Super User

@InfiniteSheldon , if you select a month or a year, and you want to show more than that you need slicer on an independent date table.

example measure

//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = eomonth(_max, -60) +1
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

Announcements

#### Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

#### Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

#### Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors