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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ShaRaj
Frequent Visitor

Hi, I am finiding difficulty in solving this expression using Dax

Expression :

if condition is positive,

then

a= x-min(x)/target(x)-Min(x)

for example X= 1,2,3,4,5

Target =10

 

Any help would be greatly appreciated. 

 

9 REPLIES 9
Anonymous
Not applicable

Hi  @ShaRaj ,

 

Here are the steps you can follow:

1. Create calculated column.

logic =
var _minx=MINX(ALL('Table'),[Value])
return
IF(
    'Table'[PN]="Positive",
DIVIDE('Table'[Value] -_minx , 'Table'[Target] -_minx),
DIVIDE('Table'[Value] -_minx , 'Table'[Target] +_minx))

2. Result:

vyangliumsft_1-1673341877920.png

 

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

hi ,

min of each category is what we need,not minimum of [value]

Anonymous
Not applicable

Hello @ShaRaj please try the same what @Anonymous told you but use this formula instead 

logic =
var _minx=CALCULATE(min(value),allexcept(table,[category]))
return
IF(
'Table'[PN]="Positive",
DIVIDE('Table'[Value] -_minx , 'Table'[Target] -_minx),
DIVIDE('Table'[Value] -_minx , 'Table'[Target] +_minx))

Anonymous
Not applicable

To convert this formula to DAX, you can use the following expression:


a = IF( x > 0, (x - MIN(x)) / (target - MIN(x)), 0 )


This expression first checks if x is positive using the IF function. If it is positive, the formula calculates (x - MIN(x)) / (target - MIN(x)), and if it is not positive, it returns 0.

 

Remember me in prayers.

Farhad

 

 

"Positive" is in text format

ShaRaj
Frequent Visitor

yes,

Also I have different set of value for different category 

for Example 

PN           Category     Value      Target
Positive        Red            1           10
Positive        Red            2          10
negative      Red            3           10
negative      Yellow       15           25
Negative       Yellow      18          25
Negative        Yellow     7            25

 

 

hi @ShaRaj 

with the mentioned dataset, what result do you expect?

if PN  is Positive do

A= x-min(x)/target(x)-Min(x)

else 

A= x-min(x)/target(x)+Min(x)

 

This is the logic,For each i have to find new "A"

Greg_Deckler
Community Champion
Community Champion

@ShaRaj Can you provide some more information on this. Are you saying you want to compute a for each value of x? So 

x=1

1 - 1 / 10 - 1 = 1 - .1 - 1 = .9 - 1 = -.1

Or ?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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