Comparing fact table value to an earlier value in same table

colinhahn

New Member
Joined
Jan 4, 2021
Messages
11
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I am trying to create a measure that will show how many members our group has gained or lost since our last month.

The data source is a spreadsheet exported from our membership software once a month, with rows for member ID, member status, and a couple of other columns.

I have transformed that data so that each row also contains the date of the report. So, my fact table looks something like this:

10/31/2021 | MemberA_ID | Active
10/31/2021 | MemberB_ID | Active
11/30/2021 | MemberA_ID | Inactive
11/30/2021 | MemberB_ID | Active
11/30/2021 | MemberC_ID | Active

The end visual will be a line graph with the report dates on the X axis and the Y axis showing two measures:
a) the count of how many members are active at the given report date AND were not active at the most previous report date (i.e., gained members)
b) the count of how many members are inactive at the given report date AND were active at the most previous report date (i.e., lost members)

I am struggling with how to create this measure. I think I need to do some manipulation of the filter contexts because the report date is filtered based on the X axis value and I need to look at the previous report date at that same value.

How can I do this?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
There might be some people that can come up with a more elegant solution.

Book1
ABCDEFGHI
1ChangesChanges
2DateMember IDStatusChange to InactiveChange to ActiveInactiveActive
310/31/2021MemberA_IDActive0110/31/202102
410/31/2021MemberB_IDActive0111/30/202111
511/30/2021MemberA_IDInactive1012/31/202102
611/30/2021MemberB_IDActive00
711/30/2021MemberC_IDActive01
812/31/2021MemberA_IDActive01
912/31/2021MemberB_IDActive00
1012/31/2021MemberC_IDActive00
1112/31/2021MemberD_IDActive01
Doug123
Cell Formulas
RangeFormula
D3:D11D3=IF(C3="Inactive",COUNTIFS($C:$C,"Active",$A:$A,MAXIFS($A:$A,$A:$A,"<"&$A3),$B:$B,$B3),0)
E3:E11E3=IF(AND(C3="Active",COUNTIFS($B:$B,$B3,$A:$A,"<"&A3)=0),1,COUNTIFS($C:$C,"Inactive",$A:$A,MAXIFS($A:$A,$A:$A,"<"&$A3),$B:$B,$B3))
G3:G5G3=SORT(UNIQUE(A3:A11))
H3:H5H3=SUMIFS($D:$D,$A:$A,G3)
I3:I5I3=SUMIFS($E:$E,$A:$A,G3)
Dynamic array formulas.
 
Upvote 0
Assuming:
a) Each member ID only appears once per month
b) you are only interested in consecutive month variance
c) Inactive members were still on your rolls in prior months so we can look for an "inactive" status. A new member wouldn't have been on the rolls so we'd have to test if their member ID was extant in prior months if you want to count them as a switch in status. That's a different set of logic then.

I think you'll have to use a new column in your data since we want to match against the member ID - that's tougher in a measure. Your table will have a filter on the month you're interested in.

(you didn't provide the table or field names so substitute as you wish). Try something along these lines...

New column...
[Active from Prior Month] =
VAR member_id = TableName[Member ID]
VAR member_status = "Active"
VAR last_month =
DATEADD ( TableName[Date], -1, MONTH )
VAR inactive_last_month =
CALCULATE (
COUNTROWS ( TableName ),
TableName[Member ID] = member_id,
MONTH ( TableName[Date] ) = MONTH ( last_month )
&& YEAR ( TableName[Date] ) = YEAR ( last_month ),
TableName[MemberStatus] <> member_status
)
VAR became_active =
IF ( inactive_last_month > 0, "Became Active", BLANK () )
RETURN
became_active

New measure...
[Newly Active]:=CALCULATE ( COUNTROWS(TableName), TableName[Active from Prior Month] = "Became Active")

And reverse the logic for the members who became inactive.
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,174
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top