Forum Discussion

akia2013's avatar
akia2013
Regular Visitor
3 years ago

Get Column Based on Selection From Disconnected Slicer

Hello, 

 

I have a report that has minimum of three tables and 4 relevant columns. I wanted to be able to pick a column from Table 1 based on the selections of Table B and Table C. Assume Table B and C are disconnected tables, with 2 values each. 

 

Originally, I thought I could use SELECTEDVALUE(B[ColumnName1]) in a column. But after much research, I found out we can only use it as a measure which causes more issue than I anticipated. By choosing the column from Table A, my count of rows necessary for my calculation changes. The SUM of the rows is fine, but the COUNT of the rows is not due to this limitation. 

 

After looking at my sample data + result, what suggestions do you have that I can achieve the correct numbers? I'm converting from Tableau to Power BI - in Tableau, a column can be selected based on the two parameters (Power BI - disconnected tables) and would not be an issue. In Power BI, it's slightly more complicated after finding out that we cannot put a selected value in a column. 

 

Raw/sample data:

 

Table A:

 

Column 1   |  Column 2 | Column 3 | Column 4

1                        7                    47              43

4                        8                 100               45

45                      99                 32                 125

65                      56               124                9

43                      1                   134                  6

3                         21               43                  5

4                          31               99                6

5                        43                 45               7

1                             2              87              65

4                         6                    1               101

 

Table B:

 

ColumnB

G

N

 

Table C:

ColumnC

O

P

 

Result:

 

If G and P are selected, then grab A's column 1

If G and O are selected, then grab A's Column 2

If N and P are selected, then grab A's Column 3

If N and O are selected, then grab A's Column 4. 

 

The numbers for that column becomes both our x axis and the sum for those same numbers becomes our y axis (running grand total). 

 

So, as an example, using the numbers above, if G and P are selected, then the results should be

X               Y (Sum of X)  Third column is the running sum of the total which I did not display here. 

12
33
412
55
4343
4545
6565

 

But the X and Y are dependent on which column from Table A is selected. 

 

If you would like for this to be a .pbix file instead, please let me know and I can remove any sensitive data and just show the 4 columns and limited dataset and convert it to import instead of Direct Query (where my original data set comes from).  

 

What I've done so far:

I already tried to do a measure with SWITCH statements above and I can achieve the sum of the numbers, but cannot get the X axis numbers. 

 

I've already created a Table D to get all unique values from all 4 columns (got numbers from 0 all the way to 300 at one point). I thought if I could connect the unique values to the values in each 4 columns, it would be a one to many relationship from Table D to Table A. That did not turn out the way I wanted because it did many to many relationship for some reason. It also would have to be connected to all 4 columns in Table A, not just one column. So, I had to drop this solution. I even thought I could use USERELATIONSHIP for inactive relationships, but kept getting a TRUE/FALSE error when I put it in a CALCULATE function.

 

 

1 Reply

  • You seem to be describing the functionality of Field Parameters - read about those and see if they help you.