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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
simber
Helper I
Helper I

Absolute value per row on filtered column

I have this table:

 

TimeForecastValueCustomer
2022-01-01 00:00:0058Customer1
2022-01-01 01:00:0047Customer1
2022-01-01 02:00:0068Customer1
2022-01-01 00:00:001012Customer2
2022-01-01 01:00:001114Customer2
2022-01-01 02:00:001513Customer2

 

How do I create a measure or calculation so I can sum my forecast column and my value column , calculate the difference (forecast-value) and then calculate the absolute value of this per row?

 

So If I create a matrix in report view and put Time in row and this new calculation in Values, I should get a matrix that looks like this:

 

TimeAbsolute Difference
2022-01-01 00:00:005
2022-01-01 01:00:006
2022-01-01 02:00:000

 

And If I sum this table for the year 2022 i get:

TimeAbsolute Difference
202211
4 REPLIES 4
v-rongtiep-msft
Community Support
Community Support

Hi @simber ,

I have create a simple sample, please refer to my pbix file to see if it helps you.

Measure = ( MAX('Table'[Forecast])-MAX('Table'[Value]))
Measure 2 = ABS(SUMX(ALL('Table'),[Measure]))
Measure 3 = ABS(SUMX(FILTER(ALL('Table'),'Table'[Time]=SELECTEDVALUE('Table'[Time])),[Measure]))

vrongtiepmsft_0-1692673885826.png

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

I tried to use your code but it didn't exactly do what I intended it to do. I want the forecast to first be aggregated for each customer and area. Then aggregate the value column the same way. After this is done I want to calculate the absolute difference between these columns. It is important to be able to filter these out. the actual table more looks like this: 

 

TimeCustomerAreaAssetForecastValue
2022-01-01 00:00Customer 1GermanyC1_A_125
2022-01-01 01:00Customer 1GermanyC1_A_136
2022-01-01 02:00Customer 1GermanyC1_A_147
2022-01-01 03:00Customer 1GermanyC1_A_158
2022-01-01 00:00Customer 1ItalyC1_A_234
2022-01-01 01:00Customer 1ItalyC1_A_241
2022-01-01 02:00Customer 1ItalyC1_A_252
2022-01-01 03:00Customer 1ItalyC1_A_268
2022-01-01 00:00Customer 2GermanyC2_A_134
2022-01-01 01:00Customer 2GermanyC2_A_141
2022-01-01 02:00Customer 2GermanyC2_A_152
2022-01-01 03:00Customer 2GermanyC2_A_168
2022-01-01 00:00Customer 2GermanyC2_A_242
2022-01-01 01:00Customer 2GermanyC2_A_249
2022-01-01 02:00Customer 2GermanyC2_A_259
2022-01-01 03:00Customer 2GermanyC2_A_277
2022-01-01 00:00Customer 2ItalyC2_A_359
2022-01-01 01:00Customer 2ItalyC2_A_371
2022-01-01 02:00Customer 2ItalyC2_A_352
2022-01-01 03:00Customer 2ItalyC2_A_368
2022-01-01 00:00Customer 3GermanyC3_A_152
2022-01-01 01:00Customer 3GermanyC3_A_168
2022-01-01 02:00Customer 3GermanyC3_A_149
2022-01-01 03:00Customer 3GermanyC3_A_159
2022-01-01 00:00Customer 3ItalyC3_A_252
2022-01-01 01:00Customer 3ItalyC3_A_268
2022-01-01 02:00Customer 3ItalyC3_A_298
2022-01-01 03:00Customer 3ItalyC3_A_242

 

 

 

From this table I want to create a measure so I can aggregate the absolute difference between the forecast and the value column AND filter based on Area and Customer. This way I can test different combinations of customers and see which combination have the lowest absolute difference.

ToddChitt
Super User
Super User

Can you give us better data sample? I see Forecast, but not Value. And be sure to include a snippet of what your desired output might look like.

If you are looking for an absolute value, then do something like this:

My Measure = SUM ( ABS ( [Forecast] - [Value] ) )




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





I kind of solved it when I'm only calculating at the lowest level (hourly).

I still have problems aggregating it to a higher time resolution so something is still off...


tot_abs = calculate(ABS(SUM(Table[difference])))

 

I calculate the difference in power query.

 

Helpful resources

Announcements
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.