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
Rana_Rumeel
Helper I
Helper I

How to Count Slicer Items

Hello Supporting Community,

Here is the Dropbo File
https://www.dropbox.com/s/l90npr8j6xllhcn/Employe_Count.pbix?dl=0

I am need to count the Employs, if from Category slicer any item is selected.
Currently "Admin" is selected and during the selected date range there are 5 Employs. So I have to display 5 as a straight line on my Line graph. but it is displaying trend instead of straight line.

While in other measure I used RemoveFilter "Date" and it is displaying 6. but it is getting one employ who is out side of the selected date range which is correct.

but I need 5 as a straight line.

Employe_Count_.png

If there is any way please suggest.

Thanks in Advance

1 ACCEPTED SOLUTION
DimaMD
Solution Sage
Solution Sage

Hi @Rana_Rumeel I don't know if I understood you correctly, but look at the file.


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com

View solution in original post

2 REPLIES 2
Michael_Hall
Regular Visitor

There is a simple solution.  You are not wanting your measure to be sliced by the dates in the visual. Therefore, just create a new calendar that is disassociated from everything and use its dates in the visual.

1. Modeling > New table

 

Calendar = CALENDAR(DATE(2019,1,1), DATE(2025,12,31))

 

2. Replace the date in the x-axis of your visual with this one.

3. You can limit the range of the x-axis to your slicer's range using visualizations > format visual > range > minimum/maximum

 

Now you have a chart with two straight lines (6 for total and 5 for emp_Count).

 

I assume you want some other data in the chart. You can make measures to refer to your new calendar. For example:

 

Emp_Count for date = 
VAR the_date = SELECTEDVALUE('Calendar'[Date])
RETURN
CALCULATE(DISTINCTCOUNT(EmployCount[Employ]),
          EmployCount[Date_Range] = the_date)

 


Or equivalently:

 

Emp_Count for date = 
CALCULATE(DISTINCTCOUNT(EmployCount[Employ]),
          TREATAS(VALUES('Calendar'[Date]), EmployCount[Date_Range]))

 

 

Result:

Emp_Count.png

 

DimaMD
Solution Sage
Solution Sage

Hi @Rana_Rumeel I don't know if I understood you correctly, but look at the file.


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com

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.

Top Solution Authors