I have the following data (just one table):
And on sheet I want to create a table that will have MonthYear
as dimension and two measures:
Current
: Counts distinct users that hadActivity = "Payment"
. Expression for this is:Count({<[Activity]={'Payment'}>} distinct [%_user_id])
and it works fine.Previous
: Counts distinct users that hadActivity = "Payment"
during previous month. For example, if the value of theMonthYear
dimension isFeb 2023
, then it should show count for theJan 2023
. Or, forJan 2023
it should show count forDec 2022
...
Do you know what the expression for the Previous
measure would be?
I tried this:
Count({<MonthYear={'$(=Date(AddMonths(MonthYear, -1), 'MMM YYYY'))'}, [Activity]={'Payment'}>} distinct [%_user_id])
but it does not work.
Maybe such a measure is not possible in this particular case?
Preparing some dummy data for myself:
You can use this expression using
Aggr()
andAbove()
instead ofPrevious()
Returning this result: