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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
KejGdr
Frequent Visitor

Distinct count of users via Created By column

I have this formula

CALCULATE(
    DISTINCTCOUNT('NG - Self Check Request List'[Created By.title]),
    YEAR('NG - Self Check Request List'[Created]) = YEAR(TODAY()),
    MONTH('NG - Self Check Request List'[Created]) = MONTH(TODAY()) - 1
)

/*CALCULATE(
    DISTINCTCOUNT('NG - Self Check Request List'[Created By.title]),
    FILTER(
        ALL('NG - Self Check Request List'),
        MONTH('NG - Self Check Request List'[Created]) = MONTH(TODAY()) - 1 &&
        YEAR('NG - Self Check Request List'[Created]) = YEAR(TODAY())
    )
)*/

 

it seems like this is an incorrect formula because it is showing 36, where it is only 19 users if checked manually on the sharepoint list. I fear that it is not counting distinctly thats why some counts were incorrect

1 ACCEPTED SOLUTION
Ahmed-Elfeel
Solution Sage
Solution Sage

Hi @KejGdr,

I hope you are doing well today❤️

 

So here is some approaches you can try and tell me if it works ☺️❤️

 

First Approache: (Using DATEADD)

Distinct Users Last Month = 
CALCULATE(
    DISTINCTCOUNT('NG - Self Check Request List'[Created By.title]),
    DATEADD(TODAY(), -1, MONTH)
)

 

Second Approache: (Using Proper date filtering) - This should work perfectly 

Distinct Users Last Month = 
VAR CurrentDate = TODAY()
VAR FirstDayLastMonth = EOMONTH(CurrentDate, -2) + 1
VAR LastDayLastMonth = EOMONTH(CurrentDate, -1)
RETURN
CALCULATE(
    DISTINCTCOUNT('NG - Self Check Request List'[Created By.title]),
    'NG - Self Check Request List'[Created] >= FirstDayLastMonth,
    'NG - Self Check Request List'[Created] <= LastDayLastMonth
)

 

Third Approache: Using PREVIOUSMONTH (if you have a date table)

Distinct Users Last Month = 
CALCULATE(
    DISTINCTCOUNT('NG - Self Check Request List'[Created By.title]),
    PREVIOUSMONTH('Date'[Date])
)

 

Bonus Approache: Debugging version to verify your data

// Firstly check if the date filtering is working correctly
Count Last Month Records = 
VAR CurrentDate = TODAY()
VAR FirstDayLastMonth = EOMONTH(CurrentDate, -2) + 1
VAR LastDayLastMonth = EOMONTH(CurrentDate, -1)
RETURN
CALCULATE(
    COUNTROWS('NG - Self Check Request List'),
    'NG - Self Check Request List'[Created] >= FirstDayLastMonth,
    'NG - Self Check Request List'[Created] <= LastDayLastMonth
)

// Then check distinct users
Distinct Users Last Month = 
VAR CurrentDate = TODAY()
VAR FirstDayLastMonth = EOMONTH(CurrentDate, -2) + 1
VAR LastDayLastMonth = EOMONTH(CurrentDate, -1)
RETURN
CALCULATE(
    DISTINCTCOUNT('NG - Self Check Request List'[Created By.title]),
    'NG - Self Check Request List'[Created] >= FirstDayLastMonth,
    'NG - Self Check Request List'[Created] <= LastDayLastMonth
)

 

Important Tips:

  • Dont forget to check for blank values

Distinct Users Last Month (No Blanks) = 
CALCULATE(
    DISTINCTCOUNT('NG - Self Check Request List'[Created By.title]),
    'NG - Self Check Request List'[Created By.title] <> BLANK(),
    DATEADD(TODAY(), -1, MONTH)
)
  • Also verify your date range by creating a simple table visual with the date range you are filtering
if this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Ahmed-Elfeel
Solution Sage
Solution Sage

Hi @KejGdr,

I hope you are doing well today❤️

 

So here is some approaches you can try and tell me if it works ☺️❤️

 

First Approache: (Using DATEADD)

Distinct Users Last Month = 
CALCULATE(
    DISTINCTCOUNT('NG - Self Check Request List'[Created By.title]),
    DATEADD(TODAY(), -1, MONTH)
)

 

Second Approache: (Using Proper date filtering) - This should work perfectly 

Distinct Users Last Month = 
VAR CurrentDate = TODAY()
VAR FirstDayLastMonth = EOMONTH(CurrentDate, -2) + 1
VAR LastDayLastMonth = EOMONTH(CurrentDate, -1)
RETURN
CALCULATE(
    DISTINCTCOUNT('NG - Self Check Request List'[Created By.title]),
    'NG - Self Check Request List'[Created] >= FirstDayLastMonth,
    'NG - Self Check Request List'[Created] <= LastDayLastMonth
)

 

Third Approache: Using PREVIOUSMONTH (if you have a date table)

Distinct Users Last Month = 
CALCULATE(
    DISTINCTCOUNT('NG - Self Check Request List'[Created By.title]),
    PREVIOUSMONTH('Date'[Date])
)

 

Bonus Approache: Debugging version to verify your data

// Firstly check if the date filtering is working correctly
Count Last Month Records = 
VAR CurrentDate = TODAY()
VAR FirstDayLastMonth = EOMONTH(CurrentDate, -2) + 1
VAR LastDayLastMonth = EOMONTH(CurrentDate, -1)
RETURN
CALCULATE(
    COUNTROWS('NG - Self Check Request List'),
    'NG - Self Check Request List'[Created] >= FirstDayLastMonth,
    'NG - Self Check Request List'[Created] <= LastDayLastMonth
)

// Then check distinct users
Distinct Users Last Month = 
VAR CurrentDate = TODAY()
VAR FirstDayLastMonth = EOMONTH(CurrentDate, -2) + 1
VAR LastDayLastMonth = EOMONTH(CurrentDate, -1)
RETURN
CALCULATE(
    DISTINCTCOUNT('NG - Self Check Request List'[Created By.title]),
    'NG - Self Check Request List'[Created] >= FirstDayLastMonth,
    'NG - Self Check Request List'[Created] <= LastDayLastMonth
)

 

Important Tips:

  • Dont forget to check for blank values

Distinct Users Last Month (No Blanks) = 
CALCULATE(
    DISTINCTCOUNT('NG - Self Check Request List'[Created By.title]),
    'NG - Self Check Request List'[Created By.title] <> BLANK(),
    DATEADD(TODAY(), -1, MONTH)
)
  • Also verify your date range by creating a simple table visual with the date range you are filtering
if this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.

Hi @Ahmed-Elfeel  , 

I double checked and it seems like 36 was the correct answer all along for last month meaning my formula has also worked which is weird..

Glad it worked! Please mark as solution if this resolved your issue 😊

KejGdr
Frequent Visitor

Hi @amitchandak  

nothing changes this is like my 1st formula that I have tried but less the ALL() function correct? and interchanged the YEAR() and MONTH()


amitchandak
Super User
Super User

@KejGdr , Try like

 

CALCULATE(
    DISTINCTCOUNT('NG - Self Check Request List'[Created By.title]),
    filter('NG - Self Check Request List', YEAR('NG - Self Check Request List'[Created]) = YEAR(TODAY()) && 
    MONTH('NG - Self Check Request List'[Created]) = MONTH(TODAY()) - 1
) )
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.