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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
adam_mac
Helper I
Helper I

Power Query: Checking if a trial customer has fully purchased trial product

Hi, i have a dataset that captures if a customer has purchased a trial of a product, if they purchased at a discount, or if they fully purchased.

 

What i would like to do is to create an additional column that captures: If a customer purchased a trial product, did they go onto fully purchase or discount purchase that same product.  For e.g. if a customer purchased a trial of apples, did they later buy a full version of apples (ive changed the products for posting here). 

 

I have no idea how i would go about doing this without creating a bunch of seperate tables, filtering, lookups etc so any help much appreciated.

 

adam_mac_1-1622036242663.png

1 ACCEPTED SOLUTION
adam_mac
Helper I
Helper I

Solved the issue from a reddit user by creating a calculated table:

 

tbl2 = var tbl = addcolumns( SUMMARIZE( filter('Table','Table'[PurchaseMethod]="Full Purchase"), 'Table'[Customer ID]), "blank",'Table'[Customer ID]) return addcolumns( SUMMARIZE( filter('Table', 'Table'[Product Name]='Table'[Product Name] &&'Table'[PurchaseMethod]="Full Purchase" &&'Table'[Customer ID] in summarize(filter(tbl,[Customer ID]),'Table'[Customer ID]) ), 'Table'[Product Name],'Table'[Customer ID],'Table'[PurchaseMethod]), "test",1)

 

and adding a column to orginal table:

FullPurchaseMade = if('Table'[PurchaseMethod]="Trial",lookupvalue(tbl2[test],tbl2[Product Name],'Table'[Product Name],tbl2[Customer ID],'Table'[Customer ID]),blank())

 

View solution in original post

3 REPLIES 3
adam_mac
Helper I
Helper I

Solved the issue from a reddit user by creating a calculated table:

 

tbl2 = var tbl = addcolumns( SUMMARIZE( filter('Table','Table'[PurchaseMethod]="Full Purchase"), 'Table'[Customer ID]), "blank",'Table'[Customer ID]) return addcolumns( SUMMARIZE( filter('Table', 'Table'[Product Name]='Table'[Product Name] &&'Table'[PurchaseMethod]="Full Purchase" &&'Table'[Customer ID] in summarize(filter(tbl,[Customer ID]),'Table'[Customer ID]) ), 'Table'[Product Name],'Table'[Customer ID],'Table'[PurchaseMethod]), "test",1)

 

and adding a column to orginal table:

FullPurchaseMade = if('Table'[PurchaseMethod]="Trial",lookupvalue(tbl2[test],tbl2[Product Name],'Table'[Product Name],tbl2[Customer ID],'Table'[Customer ID]),blank())

 

adam_mac
Helper I
Helper I

@Greg_Deckler thanks for input. Im not really sure how to apply this to my scenario. Are you able to provide further info?

Greg_Deckler
Super User
Super User

@adam_mac You should be able to use the technique here: See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors