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
Mueez
Frequent Visitor

Help needed with: Concatenatex, distinct and ralatedtable

Hi,

I am struggling with a pretty basic formula. This is the code I'm testing on daxstudio:

 

ADDCOLUMNS (
    ExternalVendorDocNumber,
    "new",
        CONCATENATEX (
            RELATEDTABLE ( GLandPostedPurchaseInvoiceLines ),
            DISTINCT(GLandPostedPurchaseInvoiceLines[Document No.]),
            ", "
        )
)

Addcolumns is just to give a row context. What I don't get is why Distinct isn't working here? This works fine if I don't use Distinct but ofcourse I just need the distinct from the column.


I've also tried using all and values but ofcourse all these functions give the same error " A table of multiple values was supplied where a single value was expected."

1 ACCEPTED SOLUTION
AlB
Super User
Super User

@Mueez 

I haven't looked in detail but try these. If it doesn't work , share the pbix with the expected result

 

ADDCOLUMNS (
    ExternalVendorDocNumber,
    "new",
        CONCATENATEX (
            DISTINCT ( RELATEDTABLE ( GLandPostedPurchaseInvoiceLines ) ),
            GLandPostedPurchaseInvoiceLines[Document No.],
            ", "
        )
)

 

ADDCOLUMNS (
    ExternalVendorDocNumber,
    "new",
        CONCATENATEX (
            CALCULATETABLE (
                DISTINCT ( GLandPostedPurchaseInvoiceLines[Document No.] ),
                RELATEDTABLE ( GLandPostedPurchaseInvoiceLines )
            ),
            GLandPostedPurchaseInvoiceLines[Document No.],
            ", "
        )
)

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

View solution in original post

7 REPLIES 7
AlB
Super User
Super User

@Mueez 

I haven't looked in detail but try these. If it doesn't work , share the pbix with the expected result

 

ADDCOLUMNS (
    ExternalVendorDocNumber,
    "new",
        CONCATENATEX (
            DISTINCT ( RELATEDTABLE ( GLandPostedPurchaseInvoiceLines ) ),
            GLandPostedPurchaseInvoiceLines[Document No.],
            ", "
        )
)

 

ADDCOLUMNS (
    ExternalVendorDocNumber,
    "new",
        CONCATENATEX (
            CALCULATETABLE (
                DISTINCT ( GLandPostedPurchaseInvoiceLines[Document No.] ),
                RELATEDTABLE ( GLandPostedPurchaseInvoiceLines )
            ),
            GLandPostedPurchaseInvoiceLines[Document No.],
            ", "
        )
)

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Mueez
Frequent Visitor

Awesome! It works! It works!!!

Thanks a million!

AlB
Super User
Super User

Hi @Mueez 

Why would you need the DISTINCT()? CONCATENATEX is an iterator and expects a scalar as second argument, so using DISTINCT() will not work.

https://dax.guide/concatenatex/

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Mueez
Frequent Visitor

Thanks @AlB for replying.

 

I need CONCATENATEX to get me just unique values as an answer. Final answer is basically supposed to look like a unique concatenation of all values of a column of the RELATEDTABLE.

@Mueez 

Sure, I didn't say you don't need CONCATENATEX, I said you don't need the DISTINCT

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Mueez
Frequent Visitor

Mueez_0-1616348623519.png

The aim is to eliminate yellow highlighted duplicates.

Mueez
Frequent Visitor

@AlB 
There are duplicates in the result that second part (expression) of CONCATENATEX is giving. I don't know how to remove those duplicate values

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.

Top Solution Authors