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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Report level filter by count of values

Is it possible to reference a report level filter in a DAX query?
I have a Date table and am trying to count the number of incidents that were closed on a specific day (easy enough)... however for my report I only want to reflect the number of incidents closed for a particular customer on each day.  I also only want to set my report critera in one place (ideally a report level filter) and don't wish to hard code the value into the DAX.

 

I've tried using SELECTEDVALUE on the field that's being filtered but that always returns NULL.

 

The (non-working) DAX statement I have is below:

 

Closed = IF(
			ISBLANK(
					CALCULATE(
								COUNTA(CombinedIncidents[IncidentNumber]),
								FILTER(CombinedIncidents,
															AND(
																CombinedIncidents[Closed Date]='Date'[Date],
																CombinedIncidents[AccountNumber] = SELECTEDVALUE(CombinedAccounts[accountnumber])															
															)
								)
					)
			),
			0,
			CALCULATE(
						COUNTA(CombinedIncidents[IncidentNumber]),
						FILTER(CombinedIncidents,
													AND(
															CombinedIncidents[Closed Date]='Date'[Date],
															CombinedIncidents[AccountNumber] = SELECTEDVALUE(CombinedAccounts[accountnumber])
														)
						)
			)
		)

Any hints would be welcome.

1 ACCEPTED SOLUTION
TeigeGao
Solution Sage
Solution Sage

Hi @Anonymous ,

It is true to use the selectedvalue() function, but you need to break some original filter, we can use the ALL() function to break some original filter, for example:

FILTER(ALL(CombinedIncidents),
AND(CombinedIncidents[Closed Date]='Date'[Date],
CombinedIncidents[AccountNumber]= SELECTEDVALUE(CombinedAccounts[accountnumber])))

Besides, we need to break the relationship between the selected field and the table CombinedIncidents.

Best Regards,

Teige

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

That's great thank you.  Turns out I was also fighting a conversion between text and numerics as well which was throwing me so my final DAX function looked like this.

 

Closed = IF(
			ISBLANK(
					CALCULATE(
								COUNTA(CombinedIncidents[IncidentNumber]),
								FILTER(ALL(CombinedIncidents),
															AND(
																CombinedIncidents[Closed Date]='Date'[Date],
																IF(ISNUMBER(CombinedIncidents[AccountNumber]),VALUE(CombinedIncidents[AccountNumber]),0) = VALUE(SELECTEDVALUE(CombinedAccounts[accountnumber]))															
															)
								)
					)
			),
			0,
			CALCULATE(
						COUNTA(CombinedIncidents[IncidentNumber]),
						FILTER(ALL(CombinedIncidents),
													AND(
															CombinedIncidents[Closed Date]='Date'[Date],
															IF(ISNUMBER(CombinedIncidents[AccountNumber]),VALUE(CombinedIncidents[AccountNumber]),0) = VALUE(SELECTEDVALUE(CombinedAccounts[accountnumber]))
														)
						)
			)
		)

Thanks once again for your assistance.

TeigeGao
Solution Sage
Solution Sage

Hi @Anonymous ,

It is true to use the selectedvalue() function, but you need to break some original filter, we can use the ALL() function to break some original filter, for example:

FILTER(ALL(CombinedIncidents),
AND(CombinedIncidents[Closed Date]='Date'[Date],
CombinedIncidents[AccountNumber]= SELECTEDVALUE(CombinedAccounts[accountnumber])))

Besides, we need to break the relationship between the selected field and the table CombinedIncidents.

Best Regards,

Teige

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors