Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Touix
Contributor III
Contributor III

Slice month - Above fonction in a chart - How to have january value if year is filtered

Hello,

In my data , I have

Monthyear,   Person_ID, top_subscription,  top_cancellation

 

 I have a chart that has MonthYear in Dimension, and I want to see sum(top_subscription) for the current month and sum(top_cancellation) for the previous month. 

So I use above Fonction. It works fine, except for januay data if a year is selected as a filter.

My question is : how to have the data for january even my year is selected ?

Thank you for your help.

 

Regards

Labels (1)
2 Replies
udit_k
Partner - Creator II
Partner - Creator II

Let vCount=num(Count(distinct Month));

use below exp:-

if(wildmatch(Month,'Jan')
,below(sum({<Year={'$(=year(addyears(yearstart(max([Start Date])),-1)))'},Month={'>=$(=month(yearstart(max([Start Date]))))<=$(=month(Max([Start Date])))'},Month=>}value),$(vCount)),
above(sum({<Year={'$(=year(addyears(yearstart(max([Start Date])),0)))'},Month={'>=$(=month(yearstart(max([Start Date]))))<=$(=month(Max([Start Date])))'},Month=>}value)))

 

udit_k_0-1689083081318.png

 

 

Touix
Contributor III
Contributor III
Author

Thank you Udit_K for your answer, but I have difficulties to understand. 

I can see in your picture that it works but can't understand your code.

If Dimension Month = Janv => sum of value for previous year and month from 1st january to the date of analysis

else take the sum of previous month (with above)

Really it is a little bit fuzzy for me, can you please help me ?

 

Thank you