Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hello Power BI Community,
I'm working on a project where I need to compare data across two different filters at a time. My dataset includes two key columns: Site and Item Name. The goal is to create a side-by-side comparison table and card that allow filtering and comparing two sets of data simultaneously. Specifically, I aim to:
I used SELECTEDVALUES for the cards and applied custom filtering so each card, table, and filter control its respective side independently. For the measure to check if an item in Filter 1 is found in Filter 2, I wrote the following DAX formula:
FoundInFilter2 =
VAR Filter2ID = [SelectedFilter2]
RETURN
IF (
CALCULATE(
COUNTROWS(
FILTER(
raw_data,
raw_data[site] = Filter2ID &&
raw_data[item_name] = MAX(raw_data[item_name])
)
)
) > 0,
"Yes",
"No"
)
Unfortunately, this measure always returns "Yes" for every item, which isn't accurate.
Could you please help me refine my approach? I need a solution where the measure correctly identifies whether an item from Filter 1 is also present in Filter 2, and both sides of the comparison work independently based on the applied filters.
Site Item Name
Site A | Item 1 |
Site A | Item 2 |
Site B | Item 2 |
Site B | Item 3 |
I hope this provides a clearer understanding of the issue I'm facing. Any advice or recommendations to improve this setup would be greatly appreciated. Thank you for your support!
Solved! Go to Solution.
How about this table?
I also set the filter.
When using the 'SELECTEDVALUE' function, I think the data column you set for the slicer should be different from the base data column.
Thank you, Mickey! I ended up being able to solve this by creating 2 identical tables reading off of eachother. Thanks again!
@sirbaklava , You can do it using interactions or Two independent tables for site and item
How Interactions Work- Split Page using interactions to compare - https://youtu.be/GIfRKzhMaR4
Compare Categorical Data Using Slicers - Compare two Brands: https://youtu.be/exN4nTewgbc
Help Pls: Comparing Items Across Two Categories with Dynamic Measures
Made this second post because I believe this is a much more clear explinations of what's happening.
Amit - thank you so much for replying to my post. I've been struggling with this issue for the last 3-4 days and I'm starting to run out of ideas here. I took a look at both of your videos and I think they're incredibly helpful. I was already tweaking the interactions to make the filters and viz act independent.
I just tried redoing this with a sample dataset with the columns site and items. Here are the 2 measures for the selected values that we're referencing and using in the card which is chosen from a filter:
Measure for Selected Baseline Site: SelectedBaselineSite = SELECTEDVALUE(sample_data[site])
Measure for Selected Comparison Site: SelectedComparisonSite = SELECTEDVALUE(sample_data[site])
Then I put the 2 filters and put site in them.
Next, I put 2 matrices and I have items in them that correspond to the site. Here are the 2 measures I created to get a yes or no on if the item is found in the other selected site:
IsInComparisonSite =
VAR SelectedComparisonSite = SELECTEDVALUE(sample_data[site])
VAR CurrentItem = SELECTEDVALUE(sample_data[item])
RETURN
IF(
COUNTROWS(
FILTER(
ALL(sample_data),
sample_data[site] = SelectedComparisonSite &&
sample_data[item] = CurrentItem
)
) > 0,
"Yes",
"No"
)
Measure for Comparison Site (checking if the item is in the baseline site):
IsInBaselineSite =
VAR SelectedBaselineSite = SELECTEDVALUE(sample_data[site])
VAR CurrentItem = SELECTEDVALUE(sample_data[item])
RETURN
IF(
COUNTROWS(
FILTER(
ALL(sample_data),
sample_data[site] = SelectedBaselineSite &&
sample_data[item] = CurrentItem
)
) > 0,
"Yes",
"No"
)
I made sure that the filters are only affecting their respective site. So filter 1 only affects card 1 and matrix 1, and interactions were turned off for filter 2, card 2, and matrix 2. I did the same thing vice versa.
However, I'm still getting all 'Yes' in the matrices for both using this method. I am not understanding what I am doing wrong. Please help.
For youre reference.
Step 0: I use your data below.
Step 1: I make 2 tables below.
- 'Sel_Item' Table -
- 'Sel_Site' Table -
Step 2: I make 2 slicers, 2 cards, 2 mesures and a table.
- 'Site' Slicer-
- 'Item' Slicer -
- Card 1 -
- Card 2 -
- Table -
I would provide a PBIX file and sample data of my own but I'm not able to do on here.
Micky thank you so much for replying to my topic.
I see that you created 2 new tables using summarize. I'm having trouble understanding how to apply this to my exact issue. Picture shown below as to what I'm really looking for:
my goal is to have the tables show the items within each site. and then a measure just saying if the item is included in the other selected comparison site.
How about this table?
I also set the filter.
When using the 'SELECTEDVALUE' function, I think the data column you set for the slicer should be different from the base data column.