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
pbhagaur
New Member

How to find non repetitive values each month

I have a table with user name column, date column along with many other columns.

I want to get count of non-repetitive distinct users each month.

Table is like this:

NameDateID
prashant1/1/2022 23123
aman1/1/2022 345
ram1/1/2022 23465
shyam2/1/2022 3467
mary2/1/2022 34
kelly2/1/2022 34234
dawn2/1/2022 656
prashant2/1/2022 675
prashant3/1/2022 3427
ram3/1/2022 7245
dawn4/1/2022 5626
ram4/1/2022 5245
shyam5/1/2022 562434
rita5/1/2022 6465

 

I want results like this:

MonthCount
Jan-22 3
Feb-22 4
Mar-22 0
Apr-22 0
May-22 1

 

Appreciate your help. Thank you

Power BI Desktop version: Sep 2021

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Untitled.png

 

Count expected measure: =
VAR _maxdateindata =
    CALCULATE ( MAX ( Data[Date] ), REMOVEFILTERS () )
VAR _currentendofmonth =
    MAX ( 'Calendar'[Endofmonth CC] )
VAR _currentmonthname =
    VALUES ( Data[Name] )
VAR _previousmonthsname =
    CALCULATETABLE (
        VALUES ( Data[Name] ),
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[Endofmonth CC] < _currentendofmonth )
    )
RETURN
    IF (
        HASONEVALUE ( 'Calendar'[Month-Year CC] ),
        IF (
            MIN ( 'Calendar'[Date] ) <= _maxdateindata,
            COUNTROWS ( EXCEPT ( _currentmonthname, _previousmonthsname ) ) + 0
        )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

4 REPLIES 4
pbhagaur
New Member

Great!! Thank you, This does solve my problem.

Is there a way I can achieve this with main table only. No calculated tables.

Hi,

If you only want to use one table, and if you do not want to use calendar table, please check the below picture and the attached pbix file.

 

Untitled.png

 

Count expected measure using only Data Table: =
VAR _maxdateindata =
    CALCULATE ( MAX ( Data[Date] ), REMOVEFILTERS () )
VAR _currentstartofmonth =
    MAX ( Data[Month-Year Sort CC] )
VAR _currentmonthname =
    VALUES ( Data[Name] )
VAR _previousmonthsname =
    CALCULATETABLE (
        VALUES ( Data[Name] ),
        FILTER ( ALL ( Data ), Data[Month-Year Sort CC] < _currentstartofmonth )
    )
RETURN
    IF (
        HASONEVALUE ( Data[Month-Year CC] ),
        COUNTROWS ( EXCEPT ( _currentmonthname, _previousmonthsname ) ) + 0
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Untitled.png

 

Count expected measure: =
VAR _maxdateindata =
    CALCULATE ( MAX ( Data[Date] ), REMOVEFILTERS () )
VAR _currentendofmonth =
    MAX ( 'Calendar'[Endofmonth CC] )
VAR _currentmonthname =
    VALUES ( Data[Name] )
VAR _previousmonthsname =
    CALCULATETABLE (
        VALUES ( Data[Name] ),
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[Endofmonth CC] < _currentendofmonth )
    )
RETURN
    IF (
        HASONEVALUE ( 'Calendar'[Month-Year CC] ),
        IF (
            MIN ( 'Calendar'[Date] ) <= _maxdateindata,
            COUNTROWS ( EXCEPT ( _currentmonthname, _previousmonthsname ) ) + 0
        )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


thanks. This solves the problem.

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.