Forum Discussion
Unique ID
- 10 years ago
buinia wrote:
In Excel this should be quite a straight forward formula of "if the Client Code is not blank, look up the Client Name and return Client Code but if it is blank look up both Client Name and Branch to return correct Client Code"
I just really struggle to put this is Power BI terms.
Thanks
Vivian
Your requirement is still confusing, if the dataset and the expectation is as below
Please follow steps
- create a proper relationship
- The DAX expression for two columns
Client Code2 = IF(ISBLANK(master[Client Code]),CONCATENATEX(branch,branch[Client Code],","),master[Client Code]&"") Sales2 = IF(ISBLANK(master[Client Code]),SUM(branch[Sales]),master[Sales])
- create a proper relationship
- 10 years ago
Hi Vivian,
I think I get it a bit better now, although I might be way off. Here's what my dataset looks like now:
Here's the updated version of the formula I provided yesterday:
Table 2 = UNION( SELECTCOLUMNS(FILTER('Table', 'Table'[Client Code] <> BLANK()), "Client Name", 'Table'[Client Name], "Client Code", 'Table'[Client Code], "Sales", 'Table'[Sales]), FILTER(ADDCOLUMNS(SELECTCOLUMNS(CROSSJOIN(DATATABLE("Index", INTEGER, {{1}, {2}, {3}}), FILTER('Table', 'Table'[Client Code] = BLANK())), "Client Name", 'Table'[Client Name], "Client Code", PATHITEM(SUBSTITUTE('Table'[Client Code 2], ",", "|"), [Index])), "Sales", LOOKUPVALUE('Table 3'[Sales], 'Table 3'[Client Name], [Client Name], 'Table 3'[Client Code], VALUE([Client Code]))), [Client Code] <> BLANK()) )Which gives this table:
Does that answer the question?
you need to create a separate table with unique client id's only and then join to it.you can the choose for example client id 'E' from the id table and then 'branch' from the existing table.
to make the table:
on the modelling tab on the ribbon click new table; in the formula bar type time_table = summarize('table','table'[client_id]) - swap out the names for what ever in correct in your model. This will provide a remove duplicates type solution for all values in the table.