Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Not applicable

Count purchases after another purchase

Hello everybody,


I've got a table like:

id | timestamp | uid | tariff_name |

1    16.01.2017   id001  tariff_A

2    16.01.2017   id002  tariff_A

3    17.01.2017   id001  tariff_B

4    18.01.2017   id002  tariff_C

5    18.01.2017   id003  tariff_A


How can i count: all purchases for id001 made after purchasing tariff_A ? (1 purchase for example table)

                            sum of id that purchase smth after purchasing tariff_A? (2 (id001 & id002 id for example table)

Resolver IV
Resolver IV

hi @Anonymous

you could do a calc column like this

CntLaterPurchases = 
      AND( table[uid] = EARLIER(table[UID]), table[id] > EARLIER(table[id]) )



Not applicable

hi @BetterCallFrank thanks for reply, i've got the following error: "EARLIER/EARLIEST refers to an earlier row context which doesn't exist", what can i do wrong?)

And what about if the first purchase was tariff_B, then tariff_A, and then tariff_C - i need to count only tariff_C - is it possible with your suggestion?

Hi @Anonymous


for your first question, try this measure:

Cnt Later Purchase of Customer:=
IF( HASONEVALUE(Table1[uid] ), VAR TheUID = VALUES( Table1[uid] ) VAR TheID = MAX( Table1[id] ) RETURN COUNTROWS( FILTER( ALL( Table1 ), AND( Table1[uid] = TheUID, Table1[id] > TheID ) ) ) )

Helpful resources

PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors