Skip to main content
cancel
Showing results for 
Search instead 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.

Reply
Gjakova
Post Patron
Post Patron

Calculate value till today and full value of previous year

Hi there, I am spending way too much time on this measure and I would think that it is actually easy but I can't wrap my head around it.

Gjakova_0-1617059540568.png

So as you may notice in the picture, the area which I surround green is 2020 and the area afterwards is 2021. You can see that in 2022 it drops to 0 (good), but I actually want this to happen at the date of TODAY ().

 

So basically for my current year (2021) I want it to continue only till the red line, but for 2020 I want to see the whole year like it is right now.

 

When that is done, I basically want to create two seperate lines. One line that shows the current year (in this case 2021) till TODAY () and the other line that shows the previous year from 01/01/2020 till 31/12/2020.

Does someone know how to do this? Thanks so much and I appreciate your help in advance!

Extra info*** I can only use Calendar[Date] on my Axis since a lot of my measures are based on SELECTEDVALUE(Calendar[Date]).

 

This is the measure I am currently using for this line chart:

 

Realised Revenue YTD =
VAR selectedDate = SELECTEDVALUE(Calender[Date])
VAR endLastYear = DATE(YEAR(selectedDate) - 1, 12, 31)

RETURN [Realised Revenue] - CALCULATE([Realised Revenue], Calender[Date] = endLastYear)
1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @Gjakova 

According to your description and requirement, I can understand what you want to get, you can try my steps:

I’ve also created some test data to follow your situation, this is part of my test data:

v-robertq-msft_0-1617265763627.png

 

  1. Create two measures like this:
CURRENTYEAR =

IF(

    MAX('Table'[Date])>=DATE(YEAR(TODAY()),1,1)&&

    MAX('Table'[Date])<=TODAY(),

    SUM('Table'[Amount]),

BLANK())
PREVIOUSYEAR =

IF(

    YEAR(MAX('Table'[Date]))=YEAR(TODAY())-1,

    SUM('Table'[Amount]),

    BLANK())
  1. Create a stacked area chart and place it like this:

v-robertq-msft_1-1617265763640.png

 

  1. Change the data color like this to meet your requirement:

v-robertq-msft_2-1617265763688.png

 

And you can get what you want.

You can download my test pbix file here

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-robertq-msft
Community Support
Community Support

Hi, @Gjakova 

According to your description and requirement, I can understand what you want to get, you can try my steps:

I’ve also created some test data to follow your situation, this is part of my test data:

v-robertq-msft_0-1617265763627.png

 

  1. Create two measures like this:
CURRENTYEAR =

IF(

    MAX('Table'[Date])>=DATE(YEAR(TODAY()),1,1)&&

    MAX('Table'[Date])<=TODAY(),

    SUM('Table'[Amount]),

BLANK())
PREVIOUSYEAR =

IF(

    YEAR(MAX('Table'[Date]))=YEAR(TODAY())-1,

    SUM('Table'[Amount]),

    BLANK())
  1. Create a stacked area chart and place it like this:

v-robertq-msft_1-1617265763640.png

 

  1. Change the data color like this to meet your requirement:

v-robertq-msft_2-1617265763688.png

 

And you can get what you want.

You can download my test pbix file here

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Gjakova , See like you need cumulative

Try a new measure like

Cumm Revenue =
var _max = maxx(ALLSELECTED('Date'),'Date'[Date])
return
CALCULATE([Realised Revenue],filter(allselected('Date'),'Date'[date] <=max('Date'[Date]) && 'Date'[Date] <= _max))

Hi @amitchandak thank you for your help, but I'm actually looking to just split these results in two measures.

So one for CURRENTYEAR (2021) and one for PREVIOUSYEAR (2020).

The green area is 2020 and the red one is 2021.

Helpful resources

Announcements
Microsoft Fabric Learn Together

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

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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