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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Pillic
Helper II
Helper II

ADD calculated Average to each row

Hello comunity,

 

I have a simple table that looks like this:

delivery | product | price | r price      

1011084259 10096246 3750,7
1011085643 10096246 3744,1
1011260543 10096246 3755,2
1011369349 10096246 3742
1011684236 10089222 2563,7
1011675242 10096246 3746,9
1011677098 10096246 3748,2
1011723460 10096246 3745,2

 

The average of column price is 35,5 = average(table[price])

Now I want to sum the average of price to each row of r price
 
delivery | product | price | r price  | r price + average price
1011084259 10096246 37

50,7

86,2
1011085643 10096246 3744,179,6
1011260543 10096246 3755,290,7
1011369349 10096246 374277,5
1011684236 10089222 2563,799,2
1011675242 10096246 3746,982,4
1011677098 10096246 3748,283,7
1011723460 10096246 3745,280,7

 

The following measure doesnt work...it sums each price to r price per row. 

VAR x = average(table[price])
RETURN CALCULATE(SUM (table[r price]) + x)

It would be great if this could be solved.

Thanks in Advance
1 ACCEPTED SOLUTION
Barthel
Solution Sage
Solution Sage

Hey,

 

Try this:

r price + average = 
VAR r_price =
    SUM ( 'table'[r price] )
VAR r_price_average =
    CALCULATE ( AVERAGE ( 'table'[r price] ), ALLSELECTED () )
RETURN
    r_price + r_price_average

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @Pillic 
You can do the following 

1.png

r price + average price = 
VAR AveragePrice = 
    CALCULATE ( AVERAGE ( Data[price] ), ALLSELECTED ( ) )
RETURN
    SUMX (
        Data,
        Data[r price] + AveragePrice
    )

Hi @tamerj1 ,

 

thanks, this provided measure is much faster if I use it with unfiltered content. Awesome. Thx

Barthel
Solution Sage
Solution Sage

Hey,

 

Try this:

r price + average = 
VAR r_price =
    SUM ( 'table'[r price] )
VAR r_price_average =
    CALCULATE ( AVERAGE ( 'table'[r price] ), ALLSELECTED () )
RETURN
    r_price + r_price_average

Hello Barthel,

 

amazing that did the job. I needed to change it a bit like this:

r price + average = 
VAR r_price =
    SUM ( 'table'[r price] )
VAR price_average =
    CALCULATE ( AVERAGE ( 'table'[price] ), ALLSELECTED () )
RETURN
    r_price + r_price_average

 

Thanks a ton for this fast response...Yall have a nice weekend, as I will now.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.