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.
I am struggling to find the solution: I have data in 1 row (company, product). I am wanting to choose a product and show all companies that have NOT purchased this product. I also want to see companies that have sold 2 or more products.
Data:
Company A Product 1
Company A Product 2
Company A Product 3
Company B Product 2
Company C Product 2
Company C Product 3
Company D Product 2
Company D Product 3
Result Required: I want to be able to select a product (Product 1) and see the list of companies that could still sell Product 1:
Company C
Company D
I don't want to see Company B because 2 or more products haven't been sold.
So I would also like to count how many companies could sell Product 1, which would be 2.
HI @Sha,
If you want to use slicer works with a 'selector' instead of a filter, please use unrelated table fields as the source of the slicer or they will filter related records first. (you can extract the product value to create a new table)
Selector= VALUES(Table[Product])
#1. It seems like a common invert selection requirement, I think you can use 'INTERSECT' function to compare with the selected products and all table products if they contain intersect values. (write a measure to compare current aggregated value and selection value and return tag then use on the visual level filter to filter records)
Measure filter =
VAR list =
INTERSECT ( ALLSELECTED ( Selector[Product] ), VALUES ( Table[Product] ) )
RETURN
IF ( COUNTROWS ( list ) = 0, "Y", "N")
#2. You can add more condition to filter records who has less than two products in current aggregate row contents.
Selection not include & product > 2 =
VAR list =
INTERSECT ( ALLSELECTED ( Selector[Product] ), VALUES ( Table[Product] ) )
RETURN
IF (
COUNTROWS ( list ) = 0
&& COUNTROWS ( VALUES ( Table[Product] ) ) >= 2,
"Y",
"N"
)
Notice: these measure filters can works with a table visual with Company as the category, count of the product as value.
If these not help, can you please share some dummy data with a similar data structure to test and coding formula? It is hard to provide the sample formula without any default data.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng
Thank you, that gets me pretty close. I'm now trying to figure out how to get the count of companies that have no product so I can do calculation with. (I see it in the table but once I remove the Client it goes back to total). I've got a pbi file, but haven't figured out how to upload for you.
Company | product |
a | table |
a | chair |
a | phone |
b | chair |
c | chair |
c | phone |
d | chair |
d | phone |
HI @Sha,
Maybe you can try this measure, it will count the company which not have selected product:
Not existed Company count =
CALCULATE (
COUNTROWS ( VALUES ( data[Company] ) ) + 0,
FILTER ( ALLSELECTED ( data ), NOT ( [Product] IN VALUE ( Product[Product] ) ) )
)
Regards,
Xiaoxin Sheng
correction:
bottom middle visual: Table...Values=Company[Company], DistinctCount of Data[Company]
@Anonymous
I'm still looking for help on how to isolate the count to use in a calculation.
@Sha ,
One way to get if you have company Dimension
Except(Company[Company],table[Company])
Other is create a measure and then use nest two measures for your two requirements
measure = count(Table[Product])+0
Filter measure =calculate(sumx(value(company[company]),[measure]),filter(Table,[measure]=0))
Filter measure 2 =calculate(sumx(value(company[company]),[measure]),filter(Table,[measure]>=2))