cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BeaBF
Super User
Super User

Min of ABS Measure

Hello everyone! This time I need you.

I need to calculate the minimum value among the absolute values ​​of a column grouped by key, in order to put in that line the sum of the same column. 

I try to explain, the data:


CHIAVE DELTA_ADJ
AAA -444,471873
AAA 380,175
BBB -28323017,83
BBB -80752,60925

 

I need to compute the sum of the column DELTA_ADJ grouped by CHIAVE, so:

-64,296873
-28403770,44

 

 

and put it in correspondence with the minimum value of the absolute value of each key, in this way:

CHIAVE DELTA_ADJ MIN VALUE
AAA -444,471873 0
AAA 380,175 -64,296873
BBB -28323017,83 0
BBB -80752,60925 -28403770,44

 

EVERYTHING MUST BE DONE BY MEASURE, WITHOUT CALCULATED COLUMNS

THX,

BF

1 ACCEPTED SOLUTION
tamerj1
Community Champion
Community Champion

Hi @BeaBF 
You can try https://we.tl/t-rWuYaQz0GU

MIN VALUE = 
VAR AbsCurrentValue = ABS ( MAX ( Data[DELTA_ADJ] ) )
VAR ChiaveTable = CALCULATETABLE ( Data, ALLEXCEPT ( Data, Data[CHIAVE] ) )
VAR GroupedBySum = SUMX ( ChiaveTable, Data[DELTA_ADJ] )
VAR AbsMinValue = MINX ( ChiaveTable, ABS ( Data[DELTA_ADJ] ) )
VAR Result = IF ( AbsCurrentValue = AbsMinValue, GroupedBySum, 0 )
RETURN
    Result

1.png

View solution in original post

2 REPLIES 2
tamerj1
Community Champion
Community Champion

Hi @BeaBF 
You can try https://we.tl/t-rWuYaQz0GU

MIN VALUE = 
VAR AbsCurrentValue = ABS ( MAX ( Data[DELTA_ADJ] ) )
VAR ChiaveTable = CALCULATETABLE ( Data, ALLEXCEPT ( Data, Data[CHIAVE] ) )
VAR GroupedBySum = SUMX ( ChiaveTable, Data[DELTA_ADJ] )
VAR AbsMinValue = MINX ( ChiaveTable, ABS ( Data[DELTA_ADJ] ) )
VAR Result = IF ( AbsCurrentValue = AbsMinValue, GroupedBySum, 0 )
RETURN
    Result

1.png

@tamerj1 

Crazy! that's just what I wanted!

A thousand thanks!

 

BF

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors