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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Flag based on value on multiple rows

Hi,

 

I have a data set that contains a unique value for each customer as well as a column which indicates what offer they received as well as the method of communication (channel).  For example;

 

IDOfferReceived LetterReceived EmailReceived Phone Call
120% offYNN
120% offNNY
215% offNYN
215% offNNY
220% offYNN
315% offYYN
320% offNYN
350% offYNY

 

   
   
   
   
   
   
   
   
   
   

 

What I need to do is create a column/columns which provide me with the channel combinations.  For example, in the above, customer number 1 has received a letter and a phone call for the same offer, so ideally i would liek to be able to have a flag that indicates that they have received this combination (letter & phone call).  The most important thing though is that this would need to be based on the same offer, as some customers may receive a letter and a call for different offers.

 

Ideally I'd love it to look like this

 

 

     Based on ID & Offer
IDOfferReceived LetterReceived EmailReceived Phone CallLetter OnlyEmail OnlyPhone Call OnlyLetter & Phone CallLetter & EmailEmail & Phone Call
120% offYNNNNNYNN
120% offNNYNNNYNN
215% offNYNNNNNNY
215% offNNYNNNNNY
220% offYNNYNNNNN
315% offYYNNNNNYN
320% offNYNNYNNNN
350% offYNYNNNYNN
1 ACCEPTED SOLUTION

Like this? See last row, a duplicate of the first row with a Y added to Email

 

image.png



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

17 REPLIES 17
Greg_Deckler
Community Champion
Community Champion

What if it looked like this for ID 1?

 

     Based on ID & Offer
IDOfferReceived LetterReceived EmailReceived Phone CallLetter OnlyEmail OnlyPhone Call OnlyLetter & Phone CallLetter & EmailEmail & Phone Call
120% offYNYNNNYNN
           
           
           
           
           
           
           


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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi,

 

that would be perfect. Any suggestions would be much appreciated.

 

Thanks

You should be able to create measures like this:

 

Email Only = 
VAR tmpTable = SUMMARIZE(Table8,[ID],[Offer],"RL",MAX([Received Letter]),"RE",MAX([Received Email]),"RP",MAX([Received Phone Call]))
VAR RL = MAXX(tmpTable,[RL])
VAR RE = MAXX(tmpTable,[RE])
VAR RP = MAXX(tmpTable,[RP])
RETURN IF(RL="Y" && RE="N" && RP="N","Y","N")


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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks very much for this Greg!  I have one quick question regarding the last piece

 

RETURN IF(RL="Y" && RE="N" && RP="N","Y","N") 

 

Does there always have to be 3 outcomes at the end (N,Y,N)?  Or can this simply be N?

Not sure I understand, there are only two outcomes, Y or N:

 

RETURN IF(RL="Y" && RE="N" && RP="N","Y","N") 

 

The red part is the logic clause. Essentially for this case that is the only scenario where you would return a Y, all other cases are N.



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

My apologies.  This makes a lot of sense.  I just got mixed up in all the Ys & Ns.

 

Is is possible to use this as a column or is it for a measure only?

 

Many thanks.

You could use it as a column if you did something along these lines (below). I really think it works better as a measure though because you can just create a table visualization with [ID], [Offer], Last of Received Letter, Last of Received Email, Last of Received Phone Call and then your measures.

 

Email Only = 
VAR tmpTable8 = FILTER(ALL(Table8),[ID]=EARLIER([ID]))
VAR tmpTable = SUMMARIZE(tmpTable8,[ID],[Offer],"RL",MAX([Received Letter]),"RE",MAX([Received Email]),"RP",MAX([Received Phone Call]))
VAR RL = MAXX(tmpTable,[RL])
VAR RE = MAXX(tmpTable,[RE])
VAR RP = MAXX(tmpTable,[RP])
RETURN IF(RL="Y" && RE="N" && RP="N","Y","N")

 

 

 

 



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi Greg, I feel like this is very close, so thank you very much. 

 

However, when I use as a column i get the following for one of our customers.  It's showing as email only when he's had a letter (DM) and email (EM).  Any ideas?

 

Capture.PNG

 

 

 

 

Sorry, that should have been:

 

Email Only Column = 
VAR tmpTable8 = FILTER(ALL(Table8),[ID]=EARLIER([ID])&&[Offer]=EARLIER([Offer]))
VAR tmpTable = SUMMARIZE(tmpTable8,[ID],[Offer],"RL",MAX([Received Letter]),"RE",MAX([Received Email]),"RP",MAX([Received Phone Call]))
VAR RL = MAXX(tmpTable,[RL])
VAR RE = MAXX(tmpTable,[RE])
VAR RP = MAXX(tmpTable,[RP])
RETURN IF(RL="N" && RE="Y" && RP="N","Y","N")

Note the first VAR statement change.



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks Greg,

 

Have applied the changes. but still getting the same result 😞

 

 

Not sure, see attached. You want Table 8.

 

 



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

What happens in your example if you duplicate your first row, but add a Y to the letter or phone call?  do you get the same answer in your calculated column?

 

Many thanks

@Anonymous

 

Hi, You can try doing this in Query Editor.

 

1. Group By ID & Offer

And Aggregation MAX of every Column (Letter, Email and PhoneCall)

 

2. Create custom Columns using "and " operator to evaluate the conditions.

 

Regards

 

Victor

 

 

 

 




Lima - Peru

Like this? See last row, a duplicate of the first row with a Y added to Email

 

image.png



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi Greg,

 

Yours looks exactly how I want it. and even though i've replicated what you've got, I can't get the right outcome.  This is very strange!

 

 

Capture.PNG

 

Many thanks

You have 2 OB's in your IF statement. One of them needs to be DM. Also, I would use ALL and not ALLSELECTED. Finally, ou have another column which you might need to filter on but I wouldn't worry about that until the other 2 issues are addressed.

 



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Greg, you're a star.  Everything works perfectly now (I've also added the extra column to filter by).

 

Appreciate your help!!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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