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

How to show data for last year if by default we show data only for current year

Hi Guys,

I'm stuck in a problem and need help!

Problem: So, I have built a dashboard in which I show the Count of deliveries from last year(whole of 2018) if the current month is January(like it is today) but when we move on to Feb, I'll be showing count for only Jan-2019 and when we move onto March, I'll be showing count for Jan 2019 and Feb 2019(You get the point). This is all fine but now the client also wants to have the ability to view the 2018 records even if we are in Feb-2019 and beyond.

I have added the aforementioned logic in the expression of charts but Now I don't know how to show the data for 2018 when we are in Feb-2019, cos according to my expression if it's Feb, only the count of Jan-2019 will be shown. I am kinda confused here. so any help will be hugely appreciated as  need to get this done quickly.

Cheers,

Pranav

Labels (3)
12 Replies
Channa
Specialist III
Specialist III

Sum({<YEAR = {"$(=Max(YEAR) - 1)"}>} value)

 

u can try 

Channa
arvind_patil
Partner - Specialist III
Partner - Specialist III

Hi Pranav,

 

Write your expression like below.

Sum ({<Date={'=>$(=Addyears(Yearstart(max(Date),-1)) )<= $(=max(Date))'}>}Sales)

Thanks & Reagrds,

Arvind Patil

sunny_talwar

What is your current expression?

pranaview
Creator III
Creator III
Author

Hi Sunny,

I'm using the below expression to do the count based on the current month

=If(Month(Today()) = 'Jan', Count({<DeliveryYear= {$(=Year(AddYears(Today(),-1)))}>}DISTINCT DeliveryNumber),Count({<DeliveryYear= {$(=Year(Today()))},DeliveryMonth = {"=DeliveryMonth < Month(AddMonths(Today(),1))"}>}DISTINCT DeliveryNumber))

Kinda looks complicated but I didn't no any other way.

Regards,
Pranav
sunny_talwar

So, when it is Jan you still want to just show the last year, right? For example, in Jan 2019 you would want to see Jan-2018 - Dec-2018. But for all other months you would want to see current year and then last year. For example, in Feb 2019 you would want to see Jan-2018 - Dec - 2018 and Jan-2019 - Feb 2019? If this is true, try this

=If(Month(Today()) = 'Jan',
Count({<DeliveryYear = {$(=Year(AddYears(Today(),-1)))}>} DISTINCT DeliveryNumber),
Count({<DeliveryYear = {$(=Year(Today()))},
DeliveryMonth = {"=DeliveryMonth < Month(AddMonths(Today(),1))"}> +
<DeliveryYear = {$(=Year(Today())-1)}>} DISTINCT DeliveryNumber)
)

or simplify it to this

=RangeSum(
Count({<DeliveryYear = {$(=Year(AddYears(Today(),-1)))}>} DISTINCT DeliveryNumber), If(Month(Today()) = 'Jan', 0, Count({<DeliveryYear = {$(=Year(Today()))}, DeliveryMonth = {"=DeliveryMonth < Month(AddMonths(Today(),1))"}>} DISTINCT DeliveryNumber) ))
pranaview
Creator III
Creator III
Author

Sunny, in Feb 2019, by default I have to show data for only Jan-2019. But if user wants to see data only for last year i.e. Jan 2018 - Dec 2018, there must be a way to achieve that.
sunny_talwar

Oh so, by default just show current year, but with the ability to see previous year? Okay may be add a button to toggle previous year expression on and off.

pranaview
Creator III
Creator III
Author

Yeah, so by default show data of current year unless it's Jan then show data of previous year and If it's not Jan then give the ability to the user to switch back to last year data.

How can I add on and off switch button? I have never tried something like this.
sunny_talwar

Can you share a sample of what you have and I can help you better