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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Gareth_Hunt
Helper II
Helper II

Calculate revenue and same period last year for any selected year

Hi Guys appreciate this may not have been the best way to setup the data initially but in have invoice data spanning several years. I have a DCalander table an linked the 2.

 

From then I created hard coded measures to calculate the revenue for the this current year as 

CY-Revenue = CALCULATE(sum('InvoiceData'[Revenue])
, FILTER(DCalandar,AND(
DCalandar[Date]>=Date(Year(TODAY()),01,01),
DCalandar[Date]<=DATE(YEAR(TODAY()),12,31))))

and the Previous year as 

PY-Revenue = CALCULATE(sum('InvoiceData'[Revenue])
, FILTER(DCalandar,AND(
DCalandar[Date]>=Date(Year(TODAY()-1),01,01),
DCalandar[Date]<=Date(Year(TODAY()-1),12,31))))

 

However I have been now asked to increase the functionality such that for any selected year selected in filter(DCalander) the revenue data would show the selected year (as current year) and prior year values acordingly. 

 

Appreicaiate any advice on how to redefine my revenue measures to make this possible.

 

With best regards

 

Gareth

 

1 ACCEPTED SOLUTION

@Gareth_Hunt 

With the above formulas, once you selected the Year in the slicer, the measures should only sum the selected year revenue for the first measure, and sum the previous year revenue of the second measure. Additional calculation is not required.

 


Paul Zheng _ Community Support Team
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

4 REPLIES 4
V-pazhen-msft
Community Support
Community Support

@Gareth_Hunt 

I guess you need add All(Table) to the filter for previousyear measure.

 

SumRevenue = SUM(InvoiceData[Revenue])

PreviousYrSumRevenue = CALCULATE([SumRevenue], PREVIOUSYEAR(DCalendar[Date]),All(DCalendar))

 

 

Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

HotChilli
Super User
Super User

If the InvoiceData is related to the date dimension correctly, this looks like 2 measures are required

SumRevenue = SUM(InvoiceData[Revenue])

PreviousYrSumRevenue = CALCULATE([SumRevenue], PREVIOUSYEAR(DCalendar[Date])

 

Hi thank you for your feedback, the issue i have is that the total revenue sums all revenues for both years

should I then calculate the year selected as being this year = SUM revenue-LYrevenue?

 

 

@Gareth_Hunt 

With the above formulas, once you selected the Year in the slicer, the measures should only sum the selected year revenue for the first measure, and sum the previous year revenue of the second measure. Additional calculation is not required.

 


Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Kudoed Authors