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
Anonymous
Not applicable

New value for same dimension on another row.

Hi all,

 

I want to make a calculation. It doesn't matter to do it with Dax or M.
I have a dataset like as below. I have a customers. Our customers segment might change month by month. 

SegmentCustomerNew_Segment04.202005.2020
XAX10
YAY01
XBX11
ZCZ11
ZDZ10
XDX01

I want to create a new column as Final_Segment
For a customer;
If columns 04.2020 and 05.2020 = 1 then Final_Segment will equal New_Segment
If column 04.2020 = 0 and 05.2020 = 1 then Final_Segment will equal New_Segment value which 04.2020 column = 1 row for same customer.
If column 04.2020 = 1 and 05.2020 = 0 then return 0

Expected output is;

SegmentCustomerNew_Segment04.202005.2020Final_Segment
XAX100
YAY01X
XBX11X
ZCZ11Z
ZDZ100
XDX01Z
2 ACCEPTED SOLUTIONS
az38
Community Champion
Community Champion

Hi @Anonymous 

for DAX

Final_Segment = 
SWITCH(TRUE(),
[04.2020] = 1 && [05.2020] = 1, [New_Segment],
[04.2020] = 0 && [05.2020] = 1, CALCULATE(FIRSTNONBLANK(Table[New_Segment], 1), ALLEXCEPT(Table, Table[Customer]), Table[04.2020] = 1,
[04.2020] = 1 && [05.2020] = 0, 0
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

I would value az38's answer, but a little change below:

Capture9.JPG

Final_Segment = 
SWITCH(TRUE(),
[04.2020] = 1 && [05.2020] = 1, FORMAT([New_Segment],"general"),
[04.2020] = 0 && [05.2020] = 1, CALCULATE(FIRSTNONBLANK('Table'[New_Segment], 1), FILTER(ALLEXCEPT('Table', 'Table'[Customer]), 'Table'[04.2020] = 1)),
[04.2020] = 1 && [05.2020] = 0, "0"
)

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

I would value az38's answer, but a little change below:

Capture9.JPG

Final_Segment = 
SWITCH(TRUE(),
[04.2020] = 1 && [05.2020] = 1, FORMAT([New_Segment],"general"),
[04.2020] = 0 && [05.2020] = 1, CALCULATE(FIRSTNONBLANK('Table'[New_Segment], 1), FILTER(ALLEXCEPT('Table', 'Table'[Customer]), 'Table'[04.2020] = 1)),
[04.2020] = 1 && [05.2020] = 0, "0"
)

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

az38
Community Champion
Community Champion

Hi @Anonymous 

for DAX

Final_Segment = 
SWITCH(TRUE(),
[04.2020] = 1 && [05.2020] = 1, [New_Segment],
[04.2020] = 0 && [05.2020] = 1, CALCULATE(FIRSTNONBLANK(Table[New_Segment], 1), ALLEXCEPT(Table, Table[Customer]), Table[04.2020] = 1,
[04.2020] = 1 && [05.2020] = 0, 0
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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