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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ArashZ
Helper I
Helper I

Count of users end of last month slicer

Hi Everyone,

 

The table below shows the active instances per day. I want to calculate the number of instances for each organization at the end of last month. For example, since we haven't reached the end of August yet, on 31 July, Organization A and B each have two instances while C has one. Also, there are two conditions: 1- Active users = Yes, and package = normal. 

 

DateInstanceOrganizationActive UserPackage
22/08/2022arAYesnormal
21/08/2022arAYesnormal
21/08/2022abAYesnormal
21/08/2022jjBNoirregular
20/08/2022ioBYesnormal
19/08/2022arAYesnormal
19/08/2022abANonormal
19/08/2022jjBNonormal
18/08/2022arAYesnormal
18/08/2022avCYesnormal
17/08/2032avCYesirregular
16/08/2022arAYesnormal
16/08/2022abAYesnormal
16/08/2022jjBYesirregular
.....
.....
31/07/2022arAYesnormal
31/07/2022abAYesnormal
31/07/2022jjBYesnormal
31/07/2022ioBYesirregular
31/07/2022avCNonormal

 

The calculated column should show this result:

 

DateOrganizationCount
31/07/2022A2
31/07/2022B1
31/07/2022C0

 

Eventually, I want to create a slicer with that calculated column. In fact, the slicer should have a range from 0 to 2.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ArashZ ,

According to your description, you want to display data for the end of the previous month for the largest date in the current date table. Right?

Here are the steps you can follow:

(1)This is my test data:

vyangliumsft_0-1661409905377.png

(2)Create calculated column - “Count” and “slice”

Count = VAR _END_OF_LAST_MONTH=EOMONTH( MAX('Table1'[Date]),-1)
var _DATE_CURRENT_LINE='Table1'[Date]
return
    IF( _END_OF_LAST_MONTH=_DATE_CURRENT_LINE, IF('Table1'[Active User]="YES" && 'Table1'[Package]="normal" , 1,0),BLANK())
slice = IF(ISBLANK('Table1'[Count]),BLANK(), CALCULATE(SUM(Table1[Count]),ALLEXCEPT(Table1,'Table1'[Organization])))

vyangliumsft_1-1661409905383.png

(3)We put the [Date],[Organization],[Count] fields in the table columns. We should select the aggregation mode [Count] column as “sum”.

vyangliumsft_2-1661409905395.png

(4)If you don’t need the “Total” in this table, you can close the “Totals” in the Format pane .

vyangliumsft_3-1661409905409.png

(5)We put the [slice] in the slice and then will meet your need.

vyangliumsft_4-1661409905414.png

If you need pbix, please click here.

case_01.pbix

 

Best Regards,

Liu Yang

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @ArashZ ,

According to your description, you want to display data for the end of the previous month for the largest date in the current date table. Right?

Here are the steps you can follow:

(1)This is my test data:

vyangliumsft_0-1661409905377.png

(2)Create calculated column - “Count” and “slice”

Count = VAR _END_OF_LAST_MONTH=EOMONTH( MAX('Table1'[Date]),-1)
var _DATE_CURRENT_LINE='Table1'[Date]
return
    IF( _END_OF_LAST_MONTH=_DATE_CURRENT_LINE, IF('Table1'[Active User]="YES" && 'Table1'[Package]="normal" , 1,0),BLANK())
slice = IF(ISBLANK('Table1'[Count]),BLANK(), CALCULATE(SUM(Table1[Count]),ALLEXCEPT(Table1,'Table1'[Organization])))

vyangliumsft_1-1661409905383.png

(3)We put the [Date],[Organization],[Count] fields in the table columns. We should select the aggregation mode [Count] column as “sum”.

vyangliumsft_2-1661409905395.png

(4)If you don’t need the “Total” in this table, you can close the “Totals” in the Format pane .

vyangliumsft_3-1661409905409.png

(5)We put the [slice] in the slice and then will meet your need.

vyangliumsft_4-1661409905414.png

If you need pbix, please click here.

case_01.pbix

 

Best Regards,

Liu Yang

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

amitchandak
Super User
Super User

@ArashZ , You can get last month end date data using today like

 

Last Month Today =
var _min = eomonth(today(),-2)+1
var _max = eomonth(today(),-1)
return CALCULATE(countrow(table) , FILTER('Date','Date'[Date] = _max))

 

 

For complete last month

 

Last Month Today =
var _min = eomonth(today(),-2)+1
var _max = eomonth(today(),-1)
return CALCULATE(countrow(table), FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

add other filters as per need

 

If you want based on the selection you can use Time Intelligence 

 

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

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

@amitchandak Hi,

 

Thanks for the answer. However, this doesn't show me the result I demonstrated in the question. I want to emphasize that the answer should look like this: 

ArashZ_0-1661176900951.png

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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