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
doingmeheadin
Frequent Visitor

Dax Measure that counts total rows for rows in filter context and gives a 0 for those outside of fil

Hi there, 

Currently when I use my slider to adjust the date parameters for a column chart dates that are outside of the filter context  disappear from the visual. I would like these dates outside of the paramenters of the slicer to remain but display and value of 0 (these figures would change dynamically as teh slider moved). I think this would be achieved by building a formular that can be used to count rows for dates within the filter contect set by a slider and for dates outside the silder reutrn 0.  For instance:

Outside of date filter? =
Var maxdate = MAX('Date Table'[Date Value])
Var mindate = Min('Date Table'[Date Value])
Var appointmentdate = MIN('Date Index'[Date of Appointment])
Return
CALCULATE(
IF(appointmentdate > maxdate || appointmentdate < mindate , 1, 0),
CROSSFILTER('Date Table'[Date Value], Appointments[Date of Appointment], None))

Then using this measure to power : 

Filtered jobs 0 =
CALCULATE(
IF([Outside of date filter?] = 1 , 0 , COUNTROWS(Appointments)),
CROSSFILTER('Date Table'[Date Value],Appointments[Date of Appointment], None))


This does not have the effect I am lookign for. Would anyone have suggestions of how to build this? 

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @doingmeheadin ,

In order to make troubleshooting and give you a suitable solution, could you please provide some sample data in your tables 'Date Table', 'Date Index' and 'Appointments(exclude sensitive data) with Text format and your expected result with backend logic and special examples? And is there any relationship among these tables? If yes, please provide the related info. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
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

@doingmeheadin , You need group by to filter measure

 

example

 

COUNTROWS(Filter(values(Appointments[ID]), [Outside of date filter?]  =1) )

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