Mathieu Ricour
Mathieu Ricour

Reputation: 378

Display parent values when child filtered in Dax

I have this table, enter image description here

and I want to display all the data of the clients who have the 'Campagne' A. So here is what I want :enter image description here

Any idea ?

Thanks.

Upvotes: 1

Views: 1189

Answers (3)

mikeinman
mikeinman

Reputation: 31

The inner calculate is a filter where the client participated in Champagne A. Using the filter, the outer calculate displays the table with the correct clients.

EVALUATE
CALCULATETABLE (
    Campaigne,
    CALCULATETABLE ( 
        DISTINCT ( Campaigne[Client] ), 
        Campaigne[Campagne] = "A" )
)

Upvotes: 0

Alexis Olson
Alexis Olson

Reputation: 40264

You can create the second table as a calculated table using the following:

TableA = FILTER(Table1,
             "A" IN CALCULATETABLE(
                        VALUES(Table1[Campagne]),
                        ALL(Table1),
                        Table1[Client] = EARLIER(Table1[Client])))

If you want a True / False calculated column on your original table, you can just use the conditional part of the above:

ClientA = "A" IN CALCULATETABLE(
                     VALUES(Table2[Campagne]),
                     ALL(Table2),
                     Table2[Client] = EARLIER(Table2[Client]))

What these are doing is taking the whole table (ALL line), filtering it to look at the Client in the current row (EARLIER line), and finding all the distinct Campagne associated with that Client any row (VALUES line) of this filtered table. Once we have those values, we check if "A" is a member.

Upvotes: 2

Tox
Tox

Reputation: 854

You could use the code from the figure below, however you should add an extra column for this.

enter image description here

Upvotes: 0

Related Questions