Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Pikachu-Power
Post Prodigy
Post Prodigy

need max in measure (for AND condition for slicer)

Hello Power BI users,

 

I have two tables customer and sales which are connected in both directions. The column color from the sales table i use as a slicer.

 

Then i wrote following measure:
 
customer_AND-Only =
VAR countRowsSales =
COUNTROWS(
    DISTINCT(
        SELECTCOLUMNS(Sales, "Color", Sales[Color])
        )
    )

RETURN
countRowsSales
 
When i put this measure in the customer table and choose for example Black and Red in the slicer i see 1 or 2 for the customers. What i want is something like
 
IF(countRowsSales = MAX(countRowsSales), "OR, AND", "OR")
 
Or if countRowsSales would return the MAX or BLANK it would be also suffcient. That would be easy to integrate in the if condition.
 
Someone an idea?
 
(I need this to switch the slicer later between AND and OR condition)
 
Many thanks!
3 REPLIES 3
Greg_Deckler
Super User
Super User

@Pikachu-Power Slicers by default are OR condition. Here is an example of creating an AND condition for a slicer: Patient Cohort (AND Slicer) - Microsoft Power BI Community


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

 

I used this way:

Slicer with AND condition in Power BI - RADACAD

 

I tested your example but the way from RADACAD looks more suitable for my case because i have some tables. Would be nice if i can just put the measure in the filter pane at the end.

 

But in my case i have just two tables instead of three tables like in RADACAD. That changes a little bit the situation 😕

 

PS: 

 

My idea with:

IF(countRowsSales = MAX(countRowsSales), "OR, AND", "OR")
was wrong. Because if i choose 3 colors MAX can be 2.
 
To make it more easy / understandable:
 
If we only refer to the RADACAD example. I think i found out my mistake: DimProduct[color] have to be outside from FactInternetSales. Otherwise the measure "Purchased Products with AND-Only Condition" doesnt work because DimCustomer would filter countRowsProducts.
 
But if we have no DimProduct table and the column color would be in the table FactInternetSales. How do we have adjust the measure "Purchased Products with AND-Only Condition" then? That is the case i described above. And DimCustomer and FactInternetSales are connected in both directions in my case.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.