The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi all,
I have a very simple table example and am wondering if anyone can help me with this semi odd formula.
Basically I want to have a filter for "Fruit", when "Fruit" is filtered in a slicer to Pear for example nothing happens. But "fruit" is filterd for Pear & Apple, the table will filter out any rows where "fruit V2" equals a fruit selected in the slicer. E.g. in the below example rows 1,2,5 would be excluded.
Thanks
Fruit | Fruit v2 |
Pear | Apple |
Apple | Apple |
Banana | Orange |
Pear | Orange |
Apple | Pear |
Solved! Go to Solution.
Hi @Jaypearce ,
I’ve completed your requirements using sample data and achieved the expected results. I’ve included snapshots of the output for your review.
When you have a chance, please let me know if this meets your expectations or if you have any suggestions for improvements.
FYI:
For Disconnected Table:
Fruit Slicer = DISTINCT(UNION(
SELECTCOLUMNS(FruitData, "Fruit", FruitData[Fruit]),
SELECTCOLUMNS(FruitData, "Fruit", FruitData[Fruit V2])
))
Used Measure:
Show Row =
VAR SelectedFruits = VALUES('Fruit Slicer'[Fruit])
VAR SelectedCount = COUNTROWS(SelectedFruits)
VAR FruitInFilter = MAX(FruitData[Fruit]) IN SelectedFruits
VAR FruitV2InFilter = MAX(FruitData[Fruit V2]) IN SelectedFruits
RETURN
SWITCH(
TRUE(),
SelectedCount = 0, 1,
SelectedCount = 1, 0,
FruitInFilter && FruitV2InFilter, 1,
0 )
Best Regards,
Community Support Team
Hi all,
Thank you for your help so far @rohit1991 @v-menakakota @burakkaragoz @bhanu_gautam, however I still cannot get it to work...
Per @v-menakakota advice I have uploaded the file example with the data set. I have added a column on the end for the results I want it to be "Include vs Exclude".
Can you please let me know if you can figure out what I am doing wrong?
https://drive.google.com/drive/folders/1ze0vl4z6aCvf_Z2snzUamM9A7a30qp9N?usp=drive_link
Thank you
Jayden
Hi @Jaypearce ,
I’ve completed your requirements using sample data and achieved the expected results. I’ve included snapshots of the output for your review.
When you have a chance, please let me know if this meets your expectations or if you have any suggestions for improvements.
FYI:
For Disconnected Table:
Fruit Slicer = DISTINCT(UNION(
SELECTCOLUMNS(FruitData, "Fruit", FruitData[Fruit]),
SELECTCOLUMNS(FruitData, "Fruit", FruitData[Fruit V2])
))
Used Measure:
Show Row =
VAR SelectedFruits = VALUES('Fruit Slicer'[Fruit])
VAR SelectedCount = COUNTROWS(SelectedFruits)
VAR FruitInFilter = MAX(FruitData[Fruit]) IN SelectedFruits
VAR FruitV2InFilter = MAX(FruitData[Fruit V2]) IN SelectedFruits
RETURN
SWITCH(
TRUE(),
SelectedCount = 0, 1,
SelectedCount = 1, 0,
FruitInFilter && FruitV2InFilter, 1,
0 )
Best Regards,
Community Support Team
Hi @Jaypearce ,
I hope the information provided above assists you in resolving the issue. If you have any additional questions or concerns, please do not hesitate to contact us. We are here to support you and will be happy to help with any further assistance you may need.
Thank you
Hi @Jaypearce ,
I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you
Hi @Jaypearce ,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.
Thank you.
Hi all,
Thank you for your help so far @rohit1991 @v-menakakota @burakkaragoz @bhanu_gautam, however I still cannot get it to work...
Per @v-menakakota advice I have uploaded the file example with the data set. I have added a column on the end for the results I want it to be "Include vs Exclude".
Can you please let me know if you can figure out what I am doing wrong?
https://drive.google.com/drive/folders/1ze0vl4z6aCvf_Z2snzUamM9A7a30qp9N?usp=drive_link
Thank you
Jayden
Hi @Jaypearce ,
The challenge comes from the difference between row context (calculated columns) and filter context (measures). If you try to do this with a measure referencing a column directly, you’ll hit the “single value cannot be determined” error.
1. Add a calculated column to your table:
ShowRow =
VAR SelectedFruits = VALUES('Table'[Fruit])
RETURN
IF(
COUNTROWS(SelectedFruits) > 1 &&
'Table'[Fruit v2] IN SelectedFruits,
0, // Exclude this row
1 // Include this row
)
2. In your visual, add a filter to only show rows where ShowRow = 1.
Hi Rohit1991,
Thank you and everyone else for the replies. Per @v-menakakota advice I have uploaded a power bi file and data set to here.
I have included a collumn called "include/exclude" for what I want the example to be. Do you know why your above formula might not be working with my data?
https://drive.google.com/drive/folders/1ze0vl4z6aCvf_Z2snzUamM9A7a30qp9N
Thanks
Hi @Jaypearce ,
Thanks for reaching out to the Microsoft fabric community forum.
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community
Regards,
Menaka.
Hi @Jaypearce ,
Teşekkürler Burak, jaypearce’in sorusu oldukça net ve bhanu_gautam’ın verdiği yanıt da doğru yolda ama biraz eksik kalmış. Kullanıcının istediği şey:
Bhanu’nun measure’ı doğru mantığı içeriyor ama görselde filtreleme yapacak şekilde uygulanmamış. Bu durumda, measure’ı bir görsel filtresi olarak kullanmak gerekiyor.
Aşağıda senin adına paylaşabileceğin, net ve uygulanabilir bir yanıt hazırladım:
Hey @jaypearce,
You're on the right track, and @bhanu_gautam’s logic is solid — just needs a small tweak to make it work as expected in the visual.
Here’s how you can do it:
ShowRow = IF ( COUNTROWS ( VALUES ( Table[Fruit] ) ) > 1, IF ( Table[Fruit v2] IN VALUES ( Table[Fruit] ), 0, 1 ), 1 )
This way:
Let me know if you want to extend this logic to more complex scenarios — happy to help.
If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.
This response was supported by AI for translation and text editing.
Hi,
Thank you so much for your help so far, however this is where I have got stuck before... I get this error. Any ideas?
"A single value for column 'Fruit V2' in table 'Table' cannot be determined. This can happen when a measure or function formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."
Thank you
@Jaypearce Add a slicer visual to your report and set it to filter based on the "Fruit" column.
Create a DAX measure that checks if "Fruit v2" is in the selected values of the slicer.
SelectedFruits =
IF (
COUNTROWS ( VALUES ( Table[Fruit] ) ) > 1,
IF (
Table[Fruit v2] IN VALUES ( Table[Fruit] ),
0,
1
),
1
)
Use the measure SelectedFruits as a filter in your table visual. Set the filter to show rows where SelectedFruits equals 1.
Proud to be a Super User! |
|