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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
InfiniteSheldon
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
amitchandak
Super User
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

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
InfiniteSheldon
Frequent Visitor

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

v-cazheng-msft
Community Support
Community Support

Hi @InfiniteSheldon,

 

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.

vcazhengmsft_0-1662704497967.png

 

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

amitchandak
Super User
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

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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