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
puneethjp
Helper I
Helper I

To calculate average of value based on weeks

Hi, 

 

We have a column which displays bins. 

$0.00 - $0.49

$0.50-$0.99

1. If you look at the pic below. For the bins $9.50 to $9.99 it has different values under "Average price test" for every week ending date. We want to average all the  average price test values generated among the same bins during different week ending dates and display only one value for the bins $9.50 to $9.99. Also, since it is repeated 9 times. As per the image below. We created a column Weeks. It should display 9 

 

2- Similary, lets says for a selected time period. I select 2022, There would be a list of averages for different bins on different week ending date.  Now, a average of 22.79 is generated  between bins $11.00-%11.49 . Instead of display the bin $11.00-%11.49, the out put should look line Max - Regular Price, similarly the smallest average should dispay Min -Regular Price under bins instead of bins for max and min regular price. 

 

puneethjp_0-1699942184476.png

 

puneethjp_1-1699942683198.png

 

 

unit_price_binsAverage Price _Testweek_ending_date
$9.50 to $9.999.91207136211-01-2020 00:00
$9.50 to $9.999.96724588618-01-2020 00:00
$9.50 to $9.999.83546259425-01-2020 00:00
$9.50 to $9.999.94314349801-02-2020 00:00
$9.50 to $9.999.922210308-02-2020 00:00
$9.50 to $9.999.98187418115-02-2020 00:00
$9.50 to $9.999.90421005422-02-2020 00:00
$9.50 to $9.999.98626865729-02-2020 00:00
$9.50 to $9.999.92783904107-03-2020 00:00
$9.00 to $9.499.20197881214-03-2020 00:00
$9.00 to $9.499.09381395321-03-2020 00:00
$9.00 to $9.499.07858483228-03-2020 00:00
$8.50 to $8.998.96049621704-04-2020 00:00
$9.50 to $9.999.98054421811-04-2020 00:00
$9.50 to $9.999.85554992518-04-2020 00:00
$9.50 to $9.999.93484487525-04-2020 00:00
$9.50 to $9.999.90488818702-05-2020 00:00
$9.50 to $9.999.60254701609-05-2020 00:00
$9.00 to $9.499.37508449716-05-2020 00:00
$9.50 to $9.999.7792647923-05-2020 00:00
$9.50 to $9.999.9930-05-2020 00:00
$9.50 to $9.999.9906-06-2020 00:00
$9.50 to $9.999.95436041813-06-2020 00:00
$9.50 to $9.999.9920-06-2020 00:00
$9.50 to $9.999.9927-06-2020 00:00
$9.50 to $9.999.97914663504-07-2020 00:00
$9.50 to $9.999.98060757711-07-2020 00:00
$9.50 to $9.999.90112938918-07-2020 00:00
$9.50 to $9.999.86396240125-07-2020 00:00
$9.50 to $9.999.91905716401-08-2020 00:00
$9.50 to $9.999.91832386408-08-2020 00:00
$9.50 to $9.999.98145070415-08-2020 00:00
$9.50 to $9.999.9922-08-2020 00:00
$9.50 to $9.999.98412850829-08-2020 00:00
$9.50 to $9.999.98086548505-09-2020 00:00
$9.50 to $9.999.97743169412-09-2020 00:00
$9.00 to $9.499.11533190119-09-2020 00:00
$8.50 to $8.998.94688435426-09-2020 00:00
$8.50 to $8.998.93513941203-10-2020 00:00
$9.00 to $9.499.01698148110-10-2020 00:00
$9.00 to $9.499.40210126617-10-2020 00:00
$9.50 to $9.999.9527991824-10-2020 00:00
$9.50 to $9.999.96453051631-10-2020 00:00
$9.50 to $9.999.9706537107-11-2020 00:00
$9.50 to $9.999.9554895114-11-2020 00:00
$9.50 to $9.999.9039119821-11-2020 00:00
$9.50 to $9.999.9928-11-2020 00:00
$9.50 to $9.999.9905-12-2020 00:00
$9.50 to $9.999.98256222512-12-2020 00:00
$9.50 to $9.999.9919-12-2020 00:00
$9.50 to $9.999.9926-12-2020 00:00
$9.50 to $9.999.9902-01-2021 00:00

 

 

Formulae we are currently using:  Could you correct/ incorrect. 

 

Max Regular Price =
VAR MaxAveragePrice =
    MAXX(
        all(Dim_Date),
        [Average Price]
    )
RETURN
    CALCULATE(
        MaxAveragePrice,
        FILTER(
            v_us_rgm_p_promo_scorecard_1,
            v_us_rgm_p_promo_scorecard_1[promoted_flag] = "non promoted"
        )
    )
 
Min Regular Price =

VAR MinAveragePrice =
    MINX(
        all(Dim_Date),
        [Average Price]
    )
RETURN
    CALCULATE(
        MinAveragePrice,
        FILTER(
            v_us_rgm_p_promo_scorecard_1,
            v_us_rgm_p_promo_scorecard_1[promoted_flag] = "non promoted"
        )
    )
Average Price _Test =

var a = [Dollar Period]
 var b = [Units Period]
 var c = DIVIDE(a,b)
 var d = SUMX(VALUES(v_us_rgm_p_promo_scorecard_1[unit_price_bins]),c)
 return
 SWITCH(TRUE(),
 SELECTEDVALUE(v_us_rgm_p_promo_scorecard_1[unit_price_bins]) = "Max-Regular Price",[Max Regular Price],
 SELECTEDVALUE(v_us_rgm_p_promo_scorecard_1[unit_price_bins])= "Min-Regular Price",[Min Regular Price] ,c)

Appreciate your time and help. 

 
Thanks 
Puneeth
1 REPLY 1
amitchandak
Super User
Super User

@puneethjp , seem like you need bucket on a measure. For that you need a table with range and use that in another measure grouped by Week and using the bucket min and max range

 

Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1...


Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k

 

 

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.