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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Clara
Advocate II
Advocate II

Need help with measure! Chart with previous year values based on current-year slicer

So, my report has two slicers: one for years and one for (store) units. Both allow for multiple selections. So far I've managed to obtain each year's profitability through this measure:

 

ProfitabilityTY = 

VAR ProfitTY = CALCULATE(SUM('Table1'[Value]);ALLSELECTED('Table1'[Year]);ALLSELECTED('Table1'[Unit]);'Table1'[ValueType]="Profit")

VAR RevenueTY = CALCULATE(SUM('Table1'[Value]);ALLSELECTED('Table1'[Year]);ALLSELECTED('Table1'[Unit]);'Table1'[ValueType]="Revenue")

RETURN ProfitTY/RevenueTY

To use in a chart visual.

 

But now I want to know the difference (growth) between each year's profitability value and the previous one's. In summary, I want to make another measure ("ProfitabilityLY", as in "last year") and a third measure which compares the two (Growth = ProfitabilityTY-ProfitabilityLY).

 

I've tried ALLSELECTED('Table1'[Year])-1 (I'm a total noob at this PBI thing) but obviously, that didn't work. Is there any obvious way I haven't thought of?

1 ACCEPTED SOLUTION
MarkLaf
Super User
Super User

You shouldn't need those ALLSELECTED filters I think, so I rewrote your ProfitabilityTY as well as providing the others. The following worked with this test data, the structure of which I guessed at from your measures:

YearValueTypeValue
2010Profit10
2010Revenue100
2011Profit20
2011Revenue100
2012Profit30
2012Revenue90
2013Profit100
2013Revenue200
2014Profit200
2014Revenue300
2015Profit150
2015Revenue350

 

 

ProfitabilityTY = 
VAR ProfitTY = CALCULATE(SUM(Table1[Value]),Table1[ValueType]="Profit")
VAR RevenueTY = CALCULATE(SUM(Table1[Value]),Table1[ValueType]="Revenue")
RETURN
DIVIDE(ProfitTY,RevenueTY)

 

 

 

ProfitabilityLT = 
CALCULATE(
    [ProfitabilityTY],
    FILTER(
        ALL(Table1[Year]),
        Table1[Year]=SELECTEDVALUE(Table1[Year])-1
    )
)

 

 

 

Growth = 
IF(
    //checks if this is first year, i.e. no data in LT, can also do isblank check on [ProfitabilityLT]
    SELECTEDVALUE(Table1[Year])=CALCULATE(MIN(Table1[Year]),ALL(Table1[Year])),
    BLANK(),
    [ProfitabilityTY]-[ProfitabilityLT]
)

 

Table visual with years and measures:

image.png

 

Does that help?

 

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

 

If,

 

  1. There is a Date column in Table1; and
  2. There is a Calendar Table; and
  3. There is a relationship from the Date column of Table1 with the Date column of the Calendar Table
  4. In the Calendar Table, you have extracted the Year from the Date by using this calculated column formula = YEAR(Calendar[Date])
  5. In your visual, you have dragged the Year from the Calendar Table

then, these simple measures will work

 

Total Profit = CALCULATE(SUM('Table1'[Value]);'Table1'[ValueType]="Profit")

Total Revenue = CALCULATE(SUM('Table1'[Value]);'Table1'[ValueType]="Revenue")

Profit % = [Total Profit]/[Total Revenue]

Profit % in PY = CALCULATE([Profit %],PREVIOUSYEAR(Calendar[Date]))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
MarkLaf
Super User
Super User

You shouldn't need those ALLSELECTED filters I think, so I rewrote your ProfitabilityTY as well as providing the others. The following worked with this test data, the structure of which I guessed at from your measures:

YearValueTypeValue
2010Profit10
2010Revenue100
2011Profit20
2011Revenue100
2012Profit30
2012Revenue90
2013Profit100
2013Revenue200
2014Profit200
2014Revenue300
2015Profit150
2015Revenue350

 

 

ProfitabilityTY = 
VAR ProfitTY = CALCULATE(SUM(Table1[Value]),Table1[ValueType]="Profit")
VAR RevenueTY = CALCULATE(SUM(Table1[Value]),Table1[ValueType]="Revenue")
RETURN
DIVIDE(ProfitTY,RevenueTY)

 

 

 

ProfitabilityLT = 
CALCULATE(
    [ProfitabilityTY],
    FILTER(
        ALL(Table1[Year]),
        Table1[Year]=SELECTEDVALUE(Table1[Year])-1
    )
)

 

 

 

Growth = 
IF(
    //checks if this is first year, i.e. no data in LT, can also do isblank check on [ProfitabilityLT]
    SELECTEDVALUE(Table1[Year])=CALCULATE(MIN(Table1[Year]),ALL(Table1[Year])),
    BLANK(),
    [ProfitabilityTY]-[ProfitabilityLT]
)

 

Table visual with years and measures:

image.png

 

Does that help?

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors