cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
deepikakumar12 Frequent Visitor
Frequent Visitor

first occurences across months


Hi,

 

Seeking guidance on how to do this ?

 

Requirement : if one of the id has repeated in any of the months ,then it should not be considered again for any other month count 

 

Lets say customer visits shop in month of jan ,same customer visits in the feb month also,but when we plot graph for month wise customer count,ideally for feb it should show count which is exclusion of customers apppeared in jan

 

So graph  needed is - Bar chart(axis-month and bars - count of ids)

For refrence  - please find the attached file,

in original source file there are many tables related,so please help me on dax formula.asapacrossmonths.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: first occurences across months

Hi @deepikakumar12 ,

 

You need to create a new column to turn the month into a number.

MonthNum =
SWITCH (
    test[Month],
    "Jan", 1,
    "Feb", 2,
    "Mar", 3,
    "Apr", 4,
    "May", 5,
    "Jun", 6,
    "Jul", 7,
    "Aug", 8,
    "Sep", 9,
    "Oct", 10,
    "Nov", 11,
    "Dec", 12
)

Then create a new column to display first occurrence.

Column =
VAR a =
    CALCULATE ( COUNTROWS ( test ), ALLEXCEPT ( test, test[ID] ) )
RETURN
    IF (
        a = 2,
        CALCULATE (
            FIRSTNONBLANK ( test[ID], 1 ),
            FILTER (
                test,
                test[ID] = EARLIER ( test[ID] )
                    && test[MonthNum]
                        = EARLIER ( test[MonthNum] ) + 1
            )
        ),
        test[ID]
    )

Now you can get the visual.2-1.PNG

 

Best Regards,

Eads

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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

1 REPLY 1
Community Support Team
Community Support Team

Re: first occurences across months

Hi @deepikakumar12 ,

 

You need to create a new column to turn the month into a number.

MonthNum =
SWITCH (
    test[Month],
    "Jan", 1,
    "Feb", 2,
    "Mar", 3,
    "Apr", 4,
    "May", 5,
    "Jun", 6,
    "Jul", 7,
    "Aug", 8,
    "Sep", 9,
    "Oct", 10,
    "Nov", 11,
    "Dec", 12
)

Then create a new column to display first occurrence.

Column =
VAR a =
    CALCULATE ( COUNTROWS ( test ), ALLEXCEPT ( test, test[ID] ) )
RETURN
    IF (
        a = 2,
        CALCULATE (
            FIRSTNONBLANK ( test[ID], 1 ),
            FILTER (
                test,
                test[ID] = EARLIER ( test[ID] )
                    && test[MonthNum]
                        = EARLIER ( test[MonthNum] ) + 1
            )
        ),
        test[ID]
    )

Now you can get the visual.2-1.PNG

 

Best Regards,

Eads

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors