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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
GeraSanz11
Frequent Visitor

Variations with specific dates

Hi everyone

 

I'm stuck with a calculation, and i've been looking at the forums but i haven't found anything similar yet.

 

The database is as follows. Captura.JPGI have 3 columns Year, id_Month and Number, and the data is monthly, from January(1) to December(12) for each year that goes from 2006 to 2016

 

i'm trying to calculate the increases or decreases for a chosen month, something like YTD formula, but the catch here is that because of the nature of this data, the total of a year isn't the sum of all the months but instead the data of December alone

 

So for example, if i want to calculate the variation of February 2016, the formula should go something like this:

 

(Sum of February 2016) minus (December 2015)

 

and so on for every February of the remaining years (Sum of February 2015 minus December 2014) 

 

So i could have a stacked column chart by year in the X axis showing each february's variation

 

i found YTD and SamePeriodLastYear but i couldn't find a way, as i said, i don't need to sum every month for a given year to calculate the total of that year.

 

Also the idea is to have a filter in the canvas so i could choose the month i want to evaluate

 

Any ideas? also thx in advance for the help

 

 

2 ACCEPTED SOLUTIONS
Zubair_Muhammad
Community Champion
Community Champion

@GeraSanz11

 

Try this MEASURE

 

Measure =
SUM ( TableName[Number] )
    - CALCULATE (
        SUM ( TableName[Number] ),
        FILTER (
            ALL ( TableName ),
            TableName[id-Month] = 12
                && TableName[YEAR]
                    = SELECTEDVALUE ( TableName[YEAR] ) - 1
        )
    )

View solution in original post

This worked perfectly! 

 

just did some adjustments like adding a report filter for the first year since it will not have a previous year to calculate 

 

 

Thank you so much!

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@GeraSanz11

 

Try this MEASURE

 

Measure =
SUM ( TableName[Number] )
    - CALCULATE (
        SUM ( TableName[Number] ),
        FILTER (
            ALL ( TableName ),
            TableName[id-Month] = 12
                && TableName[YEAR]
                    = SELECTEDVALUE ( TableName[YEAR] ) - 1
        )
    )

This worked perfectly! 

 

just did some adjustments like adding a report filter for the first year since it will not have a previous year to calculate 

 

 

Thank you so much!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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