cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DKaur3
New Member

If not crossfiltered then count

Hi,

 

I have some key values and some graphs on a dashboard. The graphs show variables over time. I want the key values to show for 2014 when nothing is selected, but when 2013 is selected on a graph, I want the key value to show the 2013 count. I'm very new to Power BI, but I though a measure might be able to do this.

 

ItemYrN = if(ISCROSSFILTERED('Table1'[Year]),calculate(counta('Table1'[Item])),calculate(counta('Table1'[Item]),filter('Table1','Table1'[Year]=2014)))

 

Item is a string field.

 

I have tried many other variations of this but just can't seem to make it work. How do I get the equation to count the crossfiltered data when ISCROSSFILTERED results in true?

 

Or any other suggestions to achieve what I want would be helpful.

 

Many thanks,

D

1 ACCEPTED SOLUTION
Greg_Deckler
Super User IV
Super User IV

I *think* what you want to do is to use ALLSELECTED in your true clause in the Calculate function versus in the false clause use the filter that you have. Then, the true portion should honor the filters that have been selected but when it is not crossfiltered, then you will get 2014 values.


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
Greg_Deckler
Super User IV
Super User IV

I *think* what you want to do is to use ALLSELECTED in your true clause in the Calculate function versus in the false clause use the filter that you have. Then, the true portion should honor the filters that have been selected but when it is not crossfiltered, then you will get 2014 values.


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Thank you!! That works perfectly!!!!

Helpful resources

Announcements
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors