Dax code in Power BI for getting specific column

46 Views Asked by At

I need to get specific column which rows are depended on another column. Here is the raw example table,

Affiliate Brand
x17 B
x17 B
x17 B
x17 B
x17 B
x17 B
1x2 B
1x2 F
1x2 F
1x2 B
1x2 F
1x2 B
1x2 F
1x2 B
1x2 F
1x2 B
1x2 F
1x2 B
x456 B
x456 B
x456 B
x456 B
x456 B
x456 B
x456 B
x456 B
x456 B

I need a measure that gives the affiliate's names according to the number of different brands they are in.

For example;

x17 affiliate is included in only "B" brand, so it will be shown only 1 row.

1x2 affiliate is included in both "B" and "F" brands, so it will be shown 2 rows.

Required Column as measure
x17
1x2
1x2
x456
2

There are 2 best solutions below

0
Ashok Anumula On

Use this which returns a table of required column:

Table = SELECTCOLUMNS(DISTINCT('Table'), "Affiliate", 'Table'[Affiliate])
0
Sam Nseir On

Measures don't return tables/columns.

If you are meaning or wanting to create a Calculated Table then you could try something similar to:

My New Table =
  SELECTCOLUMNS(
    SUMMARIZE('YourTable', [Affiliate], [Brand]),
    "Affiliate", [Affiliate]
  )