cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
patrick3 Regular Visitor
Regular Visitor

Return Value based on Multiple Distinct Values in different column

Hi all,

 

I have unique ID's with multiple payment types - I'm trying to write a formula that'll look at the different values for each ID and return the same value for both rows - i.e. if one ID has the payment types "Payment Scheme" & "Standard", it should return "Payment Scheme" in both rows. There's probably only 3 or 4 different combinations of values


This is my scenario & expected ouput:

Unique IDPayment TypesOutput
1Payment SchemePayment Scheme
1StandardPayment Scheme
2Payment SchemePayment Scheme
2StandardPayment Scheme
3Payment SchemePayment Scheme
3StandardPayment Scheme
4RefundStandard
4StandardStandard
5Payment SchemePayment Scheme
5StandardPayment Scheme
6InvoiceInvoice
6StandardInvoice
7RefundStandard
7StandardStandard
8RefundStandard
8StandardStandard
9Pay4LaterPayment Scheme
9Payment SchemePayment Scheme
9RefundPayment Scheme
10Payment SchemePayment Scheme
10StandardPayment Scheme
11InvoiceInvoice
11StandardInvoice
12InvoiceInvoice
12StandardInvoice

 

Can't figure out the DAX for this for the life of me - any tips?


Thanks,

Patrick

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Return Value based on Multiple Distinct Values in different column

See if this works:

 

Column = 
VAR __table = FILTER(ALL('Table18'),[Unique ID] = EARLIER([Unique ID]))
RETURN
SWITCH(TRUE(),
    CONTAINS(__table,[Payment Types],"Payment Scheme"),"Payment Scheme",
    CONTAINS(__table,[Payment Types],"Invoice"),"Invoice",
    CONTAINS(__table,[Payment Types],"Standard"),"Standard",
    [Payment Types]
)

Table 18 of attached.


I have book! Learn Power BI from Packt


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

View solution in original post

1 REPLY 1
Super User
Super User

Re: Return Value based on Multiple Distinct Values in different column

See if this works:

 

Column = 
VAR __table = FILTER(ALL('Table18'),[Unique ID] = EARLIER([Unique ID]))
RETURN
SWITCH(TRUE(),
    CONTAINS(__table,[Payment Types],"Payment Scheme"),"Payment Scheme",
    CONTAINS(__table,[Payment Types],"Invoice"),"Invoice",
    CONTAINS(__table,[Payment Types],"Standard"),"Standard",
    [Payment Types]
)

Table 18 of attached.


I have book! Learn Power BI from Packt


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

View solution in original post

Helpful resources

Announcements
October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Badges

Incoming: New and Improved Badges

Exciting news: We've given our badges an overhaul and added brand news ones.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 141 members 1,558 guests
Please welcome our newest community members: