Forum Discussion
Create a single filter to filter across two columns
- Anonymous5 years ago
HI Anonymous,
#1, Unpivot columns show be a better choice to handle multiple value field interactions, but it will expand your table records so it should not suitable to work with tables that include larger amount of records.
For this scenario, you can consider extracting the category field and value fields to a new table that only includes the key fields, then do unpivot on it. (it should better than direct expand raw tables records)
#2. According to your description, it seems like you are trying to create a dynamic field that based on filter selection. For this requirement, you need to create a parameter table that stored the value field names, then you can use it on the switch function to show different table field values based on current selections.
Measure = // parameter table stored A,B,C,D types of field name VAR selected = SELECTEDVALUE ( ParaTable[Field Name] ) RETURN SWITCH ( selected, "A", SUM ( Table[Field A] ), "B", SUM ( Table[Field B] ), "C", SUM ( Table[Field C] ), "D", SUM ( Table[Field D] ), //default and exception case SUM ( Table[Field A] ) )BTW, current power bi does not support creating a dynamic calculated column/table based on filter selections. Please use the measure formula instead.
Regards,Xiaoxin Sheng
Hi,
Do you know where I can read more into this please?
Thanks
E
HI Anonymous,
You can take a look at the following methods if they suitable for your scenario:
1. Unpivot columns.
Enable 'unpivot columns' on your value fields to convert them to attribute and value, then you can simply filter these records.
Unpivot columns (Power Query) - Excel (microsoft.com)
2. Calculate group and measure filter.
Introducing Calculation Groups
Applying a measure filter in Power BI - SQLBI
Regards,
Xiaoxin Sheng
- Anonymous5 years agoNot applicable
Anonymous Hi, thank you. I've taken a read to both of your solutions.
The 'Unpivot Columns' idea did work to begin with which was fantastic but when I tried to load in all the data that was needed into the tool its kept timing out during refresh.
I decided to re-think my options to allow for the large dataset and I've come up with the following solution in Excel that works:
Col1 Col2 Col3 Col4 NewCol5
fywh 12 3 £100 (=IF(Table2 Filter="Col2", B2,IF((H2 Filter="Col3",C2, ""))
hujq 10 5 £501 (=IF(Table2 Filter="Col2", B3,IF((H2 Filter="Col3",C3, ""))
I then plan on creating a line graph with Col5 as the Axis, Col4 as the value and a year column in the legend.
I know that Power BI gets funny with IF statements so I'm unsure how to get around this? I've created a new Filter Table with simply "Col2","Col3" listed (with an index) and I've created an index column in my main table. I've created a relationship between the two tables through the index column.
Do you know where I'd go from here please?
Thanks!
E
- Anonymous5 years agoNot applicable
HI Anonymous,
#1, Unpivot columns show be a better choice to handle multiple value field interactions, but it will expand your table records so it should not suitable to work with tables that include larger amount of records.
For this scenario, you can consider extracting the category field and value fields to a new table that only includes the key fields, then do unpivot on it. (it should better than direct expand raw tables records)
#2. According to your description, it seems like you are trying to create a dynamic field that based on filter selection. For this requirement, you need to create a parameter table that stored the value field names, then you can use it on the switch function to show different table field values based on current selections.
Measure = // parameter table stored A,B,C,D types of field name VAR selected = SELECTEDVALUE ( ParaTable[Field Name] ) RETURN SWITCH ( selected, "A", SUM ( Table[Field A] ), "B", SUM ( Table[Field B] ), "C", SUM ( Table[Field C] ), "D", SUM ( Table[Field D] ), //default and exception case SUM ( Table[Field A] ) )BTW, current power bi does not support creating a dynamic calculated column/table based on filter selections. Please use the measure formula instead.
Regards,Xiaoxin Sheng
- Anonymous5 years agoNot applicable
Hello,
Thank you for getting back to me on this, I'm sorry I didn't sooner however I took a period of leave so didn't think about this! I will certainly give this a try, thank you. The only other option I found that worked was bookmarks.
Thanks,
E