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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
SofiaTeles
Frequent Visitor

Calculated column displaying the first and last value/text shown in another column.

Hi, 

 

Please consider this sample purchases dataset: 

 

ClientPurchase DateOrder codePromocode
A14/04/2023A001code40
B15/04/2023A002code50
C16/04/2023A003 
D17/04/2023A004 
A18/04/2023A005code40
B19/04/2023A006code30
C20/04/2023A007code30
D21/04/2023A008 
A22/04/2023A009 
C23/04/2023A010

 

 

I'm trying to analyze the performance of the promo codes. I want to determine if customers continue to make purchases from us after using a promocode. To do this, I plan to create two calculated columns: "first_promocode" and "last_promocode" (as a customer may use multiple promo codes, I haven't decided yet which one to consider). I want these columns to be associated with the customer. The expected output is as follows:

 

ClientPurchase DateOrder codePromocodeFirst PromocodeLast promocode
A14/04/2023A001code40code40code40
B15/04/2023A002code50code50code30
C16/04/2023A003 code30code30
D17/04/2023A004   
A18/04/2023A005code40code40code40
B19/04/2023A006code30code50code30
C20/04/2023A007code30code30code30
D21/04/2023A008   
A22/04/2023A009 code40code40
C23/04/2023A010 code50

code30

 

Can you please help me find a DAX function for this? I haven't been very successful on my own.

 

Thank you in advance.

Best regards, 

Sofia Teles

5 REPLIES 5
SofiaTeles
Frequent Visitor

Hi @DOLEARY85 

 

Thank you so much for your quick reply.

 

Power Bi is returning this error: "A multi-value table was provided where a single value was expected."

 

Do you know how can I solve it? I might have simplified the dataset presented here compared to the one I'm using.

 

Thanks in advance...

 

Best regards, 

Sofia

Hi,

 

i don't suppose you can share the PBIX file?

Yes, I cannot...

I'd assume the issues was based on duplicates on the join in the table, however i tried duplicating a row in my test table and it's still working.

 

Do you have an anonymised data set i could look at?

DOLEARY85
Resident Rockstar
Resident Rockstar

Hi, 

 

try these calculated columns:

 

First Promo Used = CALCULATE(LOOKUPVALUE('Table (6)'[Promocode],'Table (6)'[Purchase Date],CALCULATE(MIN('Table (6)'[Purchase Date]))),FILTER(ALLEXCEPT('Table (6)','Table (6)'[Client]),'Table (6)'[Promocode]<>BLANK()))
 
Last Promo Used = CALCULATE(LOOKUPVALUE('Table (6)'[Promocode],'Table (6)'[Purchase Date],CALCULATE(MAX('Table (6)'[Purchase Date]))),FILTER(ALLEXCEPT('Table (6)','Table (6)'[Client]),'Table (6)'[Promocode]<>BLANK()))
 
DOLEARY85_0-1681548433462.png

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.