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
Anonymous
Not applicable

Help with wildcards (OR) (AND)

Hello!

I have the following meassure that @AlexisOlson helped me built:
It sums the sales of the End Users ( 'DB'[End User]) that sold <25000 within a Quarter, Product Group and Country WHEN 'DB'[STOCK]="NOT STOCK" and when 'DB'[Stock]<>"Not Stock", it calculates the total sales (even sales >25000)

 

CALCULATE (
    [Sales],
    FILTER (
        'DB',
        'DB'[Stock] <> "Not Stock" ||
         CALCULATE (
            [Sales],
            ALLEXCEPT (
                'DB',
                'DB'[Year],
                'DB'[Quarter],
                'DB'[Product Group],
                'DB'[Country],
                'DB'[Stock],
                'DB'[End User]
            )
        ) < 25000
    )
)

 


Now I want to see the sales <25.000 AND >10.000

The problem is that with the following meassure, it would only display the sales of 'DB'[Stock] <> "Not Stock"
Here is my meassure that does't work...

 

 

Small Sales =
VAR SmallSales =
    CALCULATE (
        [SO Net],
        ALLEXCEPT (
            'DB',
            'DB'[Year],
            'DB'[Quarter],
            'DB'[Product Group],
            'DB'[Country],
            'DB'[Stock],
            'DB'[End User]
        )
    )
RETURN
    CALCULATE (
        [SO Net],
        FILTER (
            'DB',
            'DB'[Stock] <> "Not Stock"
                || SmallSales < 25000
                && SmallSales > 10000
        )
    )



Can someone please help me and explain why it does't work?

1 ACCEPTED SOLUTION

Not quite sure on the background but as a direct translation of what I can see I wondered if this would work:

Small Sales =

CALCULATE (
    [SO Net],
    FILTER (
        'DB',
        VAR SmallSales =
		    CALCULATE (
		        [SO Net],
		        ALLEXCEPT (
		            'DB',
		            'DB'[Year],
		            'DB'[Quarter],
		            'DB'[Product Group],
		            'DB'[Country],
		            'DB'[Stock],
		            'DB'[End User]
		        )
		    )
		RETURN
		    'DB'[Stock] <> "Not Stock"
		        || (SmallSales < 25000
		        && SmallSales > 10000)
    )
)


Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

2 REPLIES 2
bcdobbs
Super User
Super User

It's not working because once you create SmallSales variable it is fixed. Your filter then iterates through table DB but compares a constant on each row.

 

Do you actually want to evaluate [S0 Net] in the row context of each row in DB?



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Not quite sure on the background but as a direct translation of what I can see I wondered if this would work:

Small Sales =

CALCULATE (
    [SO Net],
    FILTER (
        'DB',
        VAR SmallSales =
		    CALCULATE (
		        [SO Net],
		        ALLEXCEPT (
		            'DB',
		            'DB'[Year],
		            'DB'[Quarter],
		            'DB'[Product Group],
		            'DB'[Country],
		            'DB'[Stock],
		            'DB'[End User]
		        )
		    )
		RETURN
		    'DB'[Stock] <> "Not Stock"
		        || (SmallSales < 25000
		        && SmallSales > 10000)
    )
)


Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

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.