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
Anonymous
Not applicable

Why IF dax not working for outside filters

Hi Guys,

 

Hope all are doing good,

   I'm also facing the same issue from last few weeks onwards,But this is the basic thing but i'm unable to findout the way for below issue.

 

Percentage DAX :-

COUNT('Table'[Name])/CALCULATE(COUNT('Table'[Name]),ALLSELECTED('Name'))
Name Percentages
A24.36%
B20.51%
C15.30%
D8.97%
E6.41%
F6.41%
G6.41%
H5.13%
I3.85%
J2.56%

 

I want to display the categories based on percentages cutoff's

IF([Percentage]>= 10, "High","Low")
By default it was showing correct result only.But when  i was tried to apply some date range in filters  by using [Date] column .That time If function is not working.please check in below image.
 
ALow22.58%
BHigh19.35%
CLow16.13%
DLow16.13%
ELow12.90%
FLow9.68%
GHigh3.23%

 

If i write the same IF DAX by using CALCULATED MEASURE.It was showing correct result in all scenarios but i want to display as Pie chart. measures can't take in  Legend  right.

 

Appriciate for any help.

 

Regards,

Dinesh.

1 ACCEPTED SOLUTION

hi @Anonymous 

First, you should know that:

1. Calculation column/table not support dynamic changed based on filter or slicer.
2. Measure can be affected by filter/slicer, so you can use it to get dynamic summary result in a visual by its row context.

https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/

That means you could not put it into pie chart legend directly.

 

Second, for your case, you could refer to this same post:

https://community.powerbi.com/t5/Desktop/Use-measure-as-chart-legend/m-p/1237315#M547738

 

Create a measure like this:

Measure 3 = var _table=FILTER(CROSSJOIN(ADDCOLUMNS(SUMMARIZE('Table','Table'[Name ]),"_Category",[Categories Measure]),'Dim Category'),[_Category]=[Category]) return
COUNTROWS(_table)

 

and here is sample pbix file, please try it.

 

Regards,

Lin

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

8 REPLIES 8
v-lili6-msft
Community Support
Community Support

hi  @Anonymous 

the measure should work well, There should be something wrong in other, could you please share your sample pbix file for us have a test? that will be a great help.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

HI @v-lili6-msft ,@Fowmy @amitchandak 

Please follow the below link for the pbix file.

 

https://drive.google.com/file/d/1bC9wV2YsR0W6q1_Y9hxw9v3b6VtpCMTQ/view?usp=sharing

 

In that file i have created calculated column and calculated Measure.For my scenario measure was working fine But i  want to display those categories in column then only i will use it as pie chart legends right.

 

Please check the file you guys will understand my issue.

 

Thanks for responding,

Dinesh.

Hi @Anonymous ,

 

You model has many to many relationship.

 

Delete that and make it one to many relationship. It will work.

 

Regards,

Harsh Nathani

Anonymous
Not applicable

HI @harshnathani ,

 

I dont have any relationship with another table.All data comes from single table only

 

Regards,

Dinesh.

hi @Anonymous 

First, you should know that:

1. Calculation column/table not support dynamic changed based on filter or slicer.
2. Measure can be affected by filter/slicer, so you can use it to get dynamic summary result in a visual by its row context.

https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/

That means you could not put it into pie chart legend directly.

 

Second, for your case, you could refer to this same post:

https://community.powerbi.com/t5/Desktop/Use-measure-as-chart-legend/m-p/1237315#M547738

 

Create a measure like this:

Measure 3 = var _table=FILTER(CROSSJOIN(ADDCOLUMNS(SUMMARIZE('Table','Table'[Name ]),"_Category",[Categories Measure]),'Dim Category'),[_Category]=[Category]) return
COUNTROWS(_table)

 

and here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

HI @v-lili6-msft ,

 

Really thanks alot for your help.

 

Is there anyway to display the [Name] column values with percentage for when we get the High value in category?

 

For example :

If percentage of [Name] column values is morethan 30% that time

Instead on showing high,we have to  display [Name] coulmn values like(A,D,C--------etc) otherwise it should show as  "Low"

 

Thanks,

Dinesh 

 

amitchandak
Super User
Super User

@Anonymous , formula seems correct try like

maxx(summarize(Table,Table[Name],"_1",COUNT('Table'[Name])/CALCULATE(COUNT('Table'[Name]),ALLSELECTED('Name'))),IF([_1]>= 10, "High","Low"))

Fowmy
Super User
Super User

@Anonymous 

Is it possible to share your PBIX file and tell us where exactly you are not getting the result as you mentioned?  

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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.