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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

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
Community Champion
Community Champion

@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
Community Champion
Community Champion

@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
Community Champion
Community Champion

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.

AlB
Community Champion
Community Champion

@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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.