cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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

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

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors