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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Melissa
Frequent Visitor

count distinct by month

Hi All

 

 

I am triying to create a pareto chart but currently having some issues when doing so

The problem is that I need to count distinct the number of clients for the first month of the year and for the second month  just add all new cound distinc clients and so on until the end of the year

I.E January my data shows 450 unique clients February 500 but I just want to show those clients who are no part of the 450 group in January...at the end of the year I had 1450 unique clients and this is the 100% that my pareto chart has to show.

Any advice to build this pareto chart?

 

Thank you

 

1 ACCEPTED SOLUTION
v-haibl-msft
Microsoft Employee
Microsoft Employee

@Melissa

 

I’m not sure about your exact table. I write some DAX formulas for following sample table (There is another Calendar table which has relationship with this fact table). Please take a look at the result to see if it is you desired.

 

count distinct by month_1.jpg

 

Year = 
YEAR ( Table1[Date] )

 

Month =
MONTH ( Table1[Date] )

 

ExistClient = 
CALCULATE (
    COUNTROWS ( Table1 ),
    FILTER (
        ALL ( Table1 ),
        Table1[Year] = EARLIER ( Table1[Year] )
            && Table1[Month] < EARLIER ( Table1[Month] )
            && Table1[Client] = EARLIER ( Table1[Client] )
    )
)

 

DistinctCount = 
CALCULATE ( DISTINCTCOUNT ( Table1[Client] ), Table1[ExistClient] = BLANK () )

 

Percent = 
CALCULATE (
    DISTINCTCOUNT ( Table1[Client] ),
    FILTER (
        ALL ( Table1 ),
        Table1[Month] <= MAX ( Table1[Month] )
            && Table1[Year] = MAX ( Table1[Year] )
            && Table1[ExistClient] = BLANK ()
    )
)
    / CALCULATE (
        DISTINCTCOUNT ( Table1[Client] ),
        FILTER ( ALL ( Table1 ), Table1[ExistClient] = BLANK () )
)

 

count distinct by month_2.jpg

 

There are also some documents about Pareto Chart in PowerBI. Hope they are helpful to you.

http://powerbi.tips/2016/10/pareto-charting/

http://www.dutchdatadude.com/power-bi-pro-tip-pareto-analysis-with-dax/

 

Best Regards,

Herbert

View solution in original post

3 REPLIES 3
v-haibl-msft
Microsoft Employee
Microsoft Employee

@Melissa

 

I’m not sure about your exact table. I write some DAX formulas for following sample table (There is another Calendar table which has relationship with this fact table). Please take a look at the result to see if it is you desired.

 

count distinct by month_1.jpg

 

Year = 
YEAR ( Table1[Date] )

 

Month =
MONTH ( Table1[Date] )

 

ExistClient = 
CALCULATE (
    COUNTROWS ( Table1 ),
    FILTER (
        ALL ( Table1 ),
        Table1[Year] = EARLIER ( Table1[Year] )
            && Table1[Month] < EARLIER ( Table1[Month] )
            && Table1[Client] = EARLIER ( Table1[Client] )
    )
)

 

DistinctCount = 
CALCULATE ( DISTINCTCOUNT ( Table1[Client] ), Table1[ExistClient] = BLANK () )

 

Percent = 
CALCULATE (
    DISTINCTCOUNT ( Table1[Client] ),
    FILTER (
        ALL ( Table1 ),
        Table1[Month] <= MAX ( Table1[Month] )
            && Table1[Year] = MAX ( Table1[Year] )
            && Table1[ExistClient] = BLANK ()
    )
)
    / CALCULATE (
        DISTINCTCOUNT ( Table1[Client] ),
        FILTER ( ALL ( Table1 ), Table1[ExistClient] = BLANK () )
)

 

count distinct by month_2.jpg

 

There are also some documents about Pareto Chart in PowerBI. Hope they are helpful to you.

http://powerbi.tips/2016/10/pareto-charting/

http://www.dutchdatadude.com/power-bi-pro-tip-pareto-analysis-with-dax/

 

Best Regards,

Herbert

I'm wondering if I can revive this thread? I've got a similiar need. However, I would need the existing client flag to drop after 12 months has passed. Is there any way to add that additional piece of logic? 

Hi Herbert

 

You are awesome!!

 

Just tested your suggested solution and it worked perfectly in my dataset. 

The pareto chart I was trying to build now looks great!

 

Thanks again

 

Regards

Melissa

 

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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