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
nasbkrv
Regular Visitor

ABS calculation

Hi team,

I’m trying to create a measure, but I’ve some issues with syntax. Could you be able to help?

I need the following measure:
Measure % = (1 – ABS((cost1 – cost2)/cost1)*100 and if cost2>= 2*cost1 or if cost1= 0, the result should be 0.

The data should like:

 

Cost1 

4 

4 

4 

4 

4 

4 

4 

Cost2 

2 

3 

4 

5 

6 

7 

8 

Measure % 

50 

75 

100 

75 

50 

25 

0 

 

Thank you.

1 ACCEPTED SOLUTION
FrankAT
Community Champion
Community Champion

Hi @nasbkrv 

you can do it like this:

06-10-_2020_13-11-17.png

 

Measure % = 
VAR _Cost1 = MIN('Table'[Cost1 ])
VAR _Cost2 = MIN('Table'[Cost2 ])
RETURN
    IF(_Cost2 >= 2 * _Cost1 || _Cost1 = 0 ,
        0 , 
        1 - ABS((_Cost2 - _Cost1) / _Cost1)
    ) 

With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)

View solution in original post

1 REPLY 1
FrankAT
Community Champion
Community Champion

Hi @nasbkrv 

you can do it like this:

06-10-_2020_13-11-17.png

 

Measure % = 
VAR _Cost1 = MIN('Table'[Cost1 ])
VAR _Cost2 = MIN('Table'[Cost2 ])
RETURN
    IF(_Cost2 >= 2 * _Cost1 || _Cost1 = 0 ,
        0 , 
        1 - ABS((_Cost2 - _Cost1) / _Cost1)
    ) 

With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)

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.