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
MattConner
Frequent Visitor

Need help with a measure or two - Distinct Count based on multiple conditions

As a precursor , this is in a live connection environment.

 

Using the below example table titled "Parent Clients" I need a couple of measures, and I am stumped. 

 

unknown[1].png

 

First, and most important, I would like a measure that outputs a distinct count of CLIENTS with YTD REVENUE over 250 in Multiple Markets. The desired output should be "1" representing Dina only, even though Genny has revenue in 2 markets, she only have 250+ in one of them

The second measure would be a measure that gives me the total revenue of all of those clients included in the above distinct count. In this case it would be 630.

Thanks in advance.

1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @MattConner ,

 

Considering that you are under an environment using Live Connection, I created two measures.

Measure =
VAR a =
    CALCULATE (
        MAX ( 'Table'[YTD Revenue] ),
        ALLEXCEPT ( 'Table', 'Table'[Client] )
    )
VAR b =
    CALCULATE (
        MIN ( 'Table'[YTD Revenue] ),
        ALLEXCEPT ( 'Table', 'Table'[Client] )
    )
RETURN
    IF ( a >= 250 && b >= 250 && a <> b, 1, 0 )
Measure 2 =
SUMX ( FILTER ( 'Table', [Measure] = 1 ), 'Table'[YTD Revenue] )

I think you want to calculate the count, here is the measure. You can use card visual to show it

MeasureCount = 
CALCULATE(DISTINCTCOUNT('Table'[Client]),FILTER('Table',[Measure]=1))

Here is the result.

3-1.PNG

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

7 REPLIES 7
v-eachen-msft
Community Support
Community Support

Hi @MattConner ,

 

Considering that you are under an environment using Live Connection, I created two measures.

Measure =
VAR a =
    CALCULATE (
        MAX ( 'Table'[YTD Revenue] ),
        ALLEXCEPT ( 'Table', 'Table'[Client] )
    )
VAR b =
    CALCULATE (
        MIN ( 'Table'[YTD Revenue] ),
        ALLEXCEPT ( 'Table', 'Table'[Client] )
    )
RETURN
    IF ( a >= 250 && b >= 250 && a <> b, 1, 0 )
Measure 2 =
SUMX ( FILTER ( 'Table', [Measure] = 1 ), 'Table'[YTD Revenue] )

I think you want to calculate the count, here is the measure. You can use card visual to show it

MeasureCount = 
CALCULATE(DISTINCTCOUNT('Table'[Client]),FILTER('Table',[Measure]=1))

Here is the result.

3-1.PNG

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
Nathaniel_C
Super User
Super User

Hi @MattConner ,

Added a col in PQ,

Client mkt.PNGd

 

Then summarized that table in PBI

 

New1 = SUMMARIZE(REV,REV[Client],"HOW MANY MKTS", Count(REV[REV]), "TOTAL REV",SUM(REV[REV]),"How many mkts over 250",Sum(REV[Over 250]))

Client mkt1.PNG

 

Clients with 2 mkts or more over 250k = IF(MAX(New1[HOW MANY MKTS])>=2 && max(New1[How many mkts over 250])>=2,1,0)

Client mkt2.PNG

Still working on the total, but you can see it in the table if you use

m1 = IF([Clients with 2 mkts or more over 250k] = 1, max(New1[TOTAL REV]))

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@Nathaniel_C  The actual data model is a Live Connection, so (from what I can tell) I cannot use power Querie. 

unknown[1].png

Ok,

will move it to PBI





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Over 250 = IF((REV[REV])>250,1)

Adds the same col to the table which I called REV, and then the New1 table picks it up with no change.

 

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Sum REV for Participating Clients = CALCULATE(SUM(New1[TOTAL REV]),Filter(New1,[Clients with 2 mkts or more over 250k] ))

Hi @MattConner ,

 

Sums the rev for Clients who are eligible.

 

Client mkt3.PNG

 

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @MattConner ,

One more change, I made Genny and came up with a new measure which used COUNT and filtered the table by those who qualified.

 

Number of clients with 2 and over 250k = CALCULATE(COUNT(New1[Client]),Filter(New1,[Clients with 2 mkts or more over 250k] ))

Client mkt4.PNG

 

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.