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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Yeztrom
Helper I
Helper I

Calculate median from calculated column

Hi,

 

I have de next calculated table.

 

Yeztrom_0-1651532905260.png

 

That table is generated with the next measure.

 

VAR _VW_Prices_Mode =
FILTER(
            _VW_Prices_Mode_Retalers_No_Model,
             [Year_Week|Max_Rep] IN _VW_Prices_List_Year_Weeek_and_Max_Rep
)
 
I need to calculate the median of the column product_current_price gruped by the columns master_product_id and related year_week.
 
I tried with the next measure, but it did not work.
 
VAR _VW_Prices_Mode_Clear =
SUMMARIZE(
                     _VW_Prices_Mode,
                    [master_product_id],
                    [related year_week],
                   "Mode",MEDIANX(_VW_Prices_Mode,[product_current_price])
)
 
The result was this.
Yeztrom_1-1651533453153.png

The "Mode" column was not grouped by  "master_product_id"  and by "related year_week"

 

I thought use GROUPBY but it seems that it is not compatible with MEDIANX

 

I would like to know if there is a way to do this.

 

 

 

 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Yeztrom , This will take complete column, Try like

If needed use add columns to add the below column

 

VAR _VW_Prices_Mode_Clear =
SUMMARIZE(
_VW_Prices_Mode,
[master_product_id],
[related year_week],
"price",[product_current_price]
)

 

New column = MEDIANX(filter(Table, [master_product_id] = earlier([master_product_id]) && [related year_week] = earlier([related year_week]) ), [Price])

 

or

 

New column = MEDIANX(filter(Table,  [related year_week] = earlier([related year_week]) ), [Price])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Yeztrom , This will take complete column, Try like

If needed use add columns to add the below column

 

VAR _VW_Prices_Mode_Clear =
SUMMARIZE(
_VW_Prices_Mode,
[master_product_id],
[related year_week],
"price",[product_current_price]
)

 

New column = MEDIANX(filter(Table, [master_product_id] = earlier([master_product_id]) && [related year_week] = earlier([related year_week]) ), [Price])

 

or

 

New column = MEDIANX(filter(Table,  [related year_week] = earlier([related year_week]) ), [Price])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks, 

 

The solution was:

VAR _VW_Prices_Mode_Clear =
SUMMARIZE(
_VW_Prices_Mode,
[master_product_id],
[related year_week],
"Mode",MEDIANX(FILTER(_VW_Prices_Mode, [master_product_id] = EARLIER([master_product_id]) && [related year_week] = EARLIER([related year_week]) ), [product_current_price])
)

 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors