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
luisccmm
Helper II
Helper II

count distinct filtering with multiple values

Hi,

 

I am new to Power BI, but used to Qlik and a bit confused at the moment.

 

1)Question 1: I am trying to" count Clients_id that their Client_type do not belong to Level1, Level2, Level3 and Level 4.

 

MY  DAX ATTEMPT:

 

 

 

client_id_count=

CALCULATE
(
    count('SALES table'[Client_id]),
     NOT [Client_type]  IN {"LEVEL1","LEVEL2","LEVEL3","LEVEL4"}
) 

 

 

 

 

2) Question 2: On the other hand I would like to know how to mimic "Contains concept using maybe some string as '*' ". I was used to do it that way in Qlik, but not sure how it is in PowerBI. I mean something like  "*1",*2",*3",*4".

 

NOTE: Client Type  distinct values dimensions are close 30. (Level 1.... Level 30)

 

 

 

client_id_count=
CALCULATE
(
    count('SALES table'[Client_id]),
     NOT [Client_type]  IN {"*1","*2","*3","*3"}
) 

 

 

 

 

Any help will be appreciated!😀

1 ACCEPTED SOLUTION

This measure works @luisccmm

client_id_count = 
CALCULATE(
    COUNTROWS(Hoja1),
    FILTER(
        VALUES(Hoja1[Client_type]),
        NOT( Hoja1[Client_type] IN {"LEVEL1","LEVEL2","LEVEL3","LEVEL4"})
        )
)

edhans_0-1606755020286.png



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

9 REPLIES 9
edhans
Super User
Super User

@luisccmm it would really help if you posted some sample data. @mahoneypat and I are kind of guessing how your data looks, and you just keep coming back with "it doesn't work."

How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

This measure works @luisccmm

client_id_count = 
CALCULATE(
    COUNTROWS(Hoja1),
    FILTER(
        VALUES(Hoja1[Client_type]),
        NOT( Hoja1[Client_type] IN {"LEVEL1","LEVEL2","LEVEL3","LEVEL4"})
        )
)

edhans_0-1606755020286.png



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

@edhans to be more precise still part of the question is unsolved because I want to SAY exactly that Client_type DOES NOT ENDS in 1, 2, 3 and 4. This is my real propose thats why my attemps was something like the following.

 

client_id_count=
CALCULATE
(
    count('SALES table'[Client_id]),
     NOT [Client_type]  IN {"*1","*2","*3","*3"}
) 
mahoneypat
Employee
Employee

Here is one way to do it.

 

Client id count =
CALCULATE (
    COUNT ( 'Sales Table'[Client_id] ),
    FILTER (
        ALL ( 'Sales Table'[Client_type] ),
        NOT (
            SEARCH (
                "Level",
                'Sales Table'[Client_type],
                ,
                0
            ) > 0
        )
    )
)

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@mahoneypat   thanks for your proposal, but there are 30 distinct values on Client Type dimension that DO include "Level" word, I am just trying to NOT include  Leve 1-  Level2 - Level 3 and Level4 ON my Count Measure.

 

 

Note that you can use wildcards in the one I provided (* for multi and ? for single character).  But here is another expression that may be what you are looking for.  It also allows the use of wildcards.

Client id count 2 =
CALCULATE (
    COUNT ( 'Sales Table'[Client_id] ),
    FILTER (
        ALL ( 'Sales Table'[Client_type] ),
        NOT (
            VAR thisclient = 'Sales Table'[Client_type]
            RETURN
                COUNTROWS (
                    FILTER (
                        {
                            "*1",
                            "*2"
                        },
                        CONTAINSSTRING (
                            thisclient,
                            [Value]
                        )
                    )
                ) > 0
        )
    )
)

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


edhans
Super User
Super User

Did your dax attempt work?

How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

@edhans No ti didn´t work.

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.