Forum Discussion
Switch DAX showing wrong results
Hi, It seems its givign me still worng results
need your help what i am missing,
I need if my achvd% between 0 to 4 then Cvalue shoudl give me 0
IF Achvd % between 0.4 to 0.6 theen 60 like that , achvd% data type i made % ,
can someone help me what is worng
Thsi is my formula
6 Replies
- amitchandak
Super User
bilalkhokar73 , measure seem correct. But make sure that achvd% is percent measure (marked as % in measure tool) . And these values are below 1 and shown as *100.
If not logic has to change
Try like this
cvalues = SWITCH(TRUE(),
,[achvd%]<=0.4,"0",
[achvd%]<=0.6,"60",
[achvd%]<=0.70,"70",
[achvd%]<=0.80,"80",
[achvd%]<=0.9,"90",
[achvd%]<=1,"100",
[achvd%]<=9.9,"125.5",
[achvd%]<=100,"14100",
"0")Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
- bilalkhokar73
Helper IV
- bilalkhokar73
Helper IV
Hi amit thsi is my power bi link
https://www.dropbox.com/s/7zct41wc47xudt9/test.pbix?dl=0
this is my file here achvd% is coming wrong, I need one more new column name that will be achvd% divided by 100 as a new column
amitchandak
- VahidDM
Super User
I'm not sure I understand your question well or not, but please try the below measure:
cvalues = SWITCH(TRUE(), AND(max('Table'[achvd%])>=0.0,max('Table'[achvd%])<=0.4),"0", AND(max('Table'[achvd%])>0.4,max('Table'[achvd%])<=0.6),"60", AND(max('Table'[achvd%])>0.61,max('Table'[achvd%])<=0.70),"70", AND(max('Table'[achvd%])>0.71,max('Table'[achvd%])<=0.80),"80", AND(max('Table'[achvd%])>0.81,max('Table'[achvd%])<=0.9),"90", AND(max('Table'[achvd%])>0.91,max('Table'[achvd%])<=1),"100", AND(max('Table'[achvd%])>1.1,max('Table'[achvd%])<=9.9),"125.5", AND(max('Table'[achvd%])>14,max('Table'[achvd%])<=100),"14100", "0")the result would be as follow:
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!
- bilalkhokar73
Helper IV
- AnonymousNot applicable
Hi bilalkhokar73 ,
You can convert it to measure.
1. Create measure.、
Measure = SWITCH( TRUE(), AND([achvd%]>=0.000001,[achvd%]<=0.0999999),"001111", AND([achvd%]>=0,[achvd%]<=0.4),"0", AND([achvd%]>0.41,[achvd%]<=0.6),"60", AND([achvd%]>0.61,[achvd%]<=0.7),"70", AND([achvd%]>0.71,[achvd%]<=0.8),"80", AND([achvd%]>0.81,[achvd%]<=0.9),"90", AND([achvd%]>0.91,[achvd%]<=1),"100", AND([achvd%]>1.1,[achvd%]<=9.9),"125.5", AND([achvd%]>14,[achvd%]<=100),"14100", "0")2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly