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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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