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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
MikaelB
Frequent Visitor

Populate user rows with store name from first purchase

Hi experts.

Problem:
Trying to create calculated column that looks up which store user used in their first purchase and populate column with that data.


Wanted outcome:

USER_ID

PURCHASE_DATE

STORE_NAME

FIRST_STORE_NAME (wanted outcome)

1

1.1.2020

A

A

1

2.1.2020

B

A

1

3.1.2020

B

A

2

1.1.2020

C

C

2

2.1.2020

B

C

2

3.1.2020

C

C

3

1.1.2020

A

A

3

2.1.2020

A

A

3

3.1.2020

C

A

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@MikaelB , Create a new column like

 

New column =
var _max = Minx(filter(Table, [USER_ID] = earlier([USER_ID])),[PURCHASE_DATE])
return
[Value] -maxx(filter(Table, [PURCHASE_DATE] = _max && [USER_ID] = earlier([USER_ID])),[STORE_NAME])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
selimovd
Super User
Super User

Hey @MikaelB ,

 

you should get the result with the following calculated column:

FIRST_STORE_NAME =
VAR vRowUser = myTable[USER_ID]
VAR vFirstPurchase =
    CALCULATE(
        MIN( myTable[PURCHASE_DATE] ),
        ALLEXCEPT(
            myTable,
            myTable[USER_ID]
        )
    )
RETURN
    CALCULATE(
        MIN( myTable[STORE_NAME] ),
        myTable[USER_ID] = vRowUser,
        myTable[PURCHASE_DATE] = vFirstPurchase,
        ALL( myTable )
    )

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

 

amitchandak
Super User
Super User

@MikaelB , Create a new column like

 

New column =
var _max = Minx(filter(Table, [USER_ID] = earlier([USER_ID])),[PURCHASE_DATE])
return
[Value] -maxx(filter(Table, [PURCHASE_DATE] = _max && [USER_ID] = earlier([USER_ID])),[STORE_NAME])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

This worked. Thank you for the solution. Danced around this the whole day 🙂

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors