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
tmrwall
New Member

Calculate column after filters applied

I'm new to Power BI and I am struggling to plot a calculated ratio based on filters. I would like to calculate the average unit price for the different quarters after filters have been applied to Category.

 

For example, my dataset looks like this:

PowerBI_Query1.png

I would like the results that are plotted to look like this, if Category <> C filter is applied:

PowerBI_Query2.png

 

 

Many thanks in advance!

2 ACCEPTED SOLUTIONS
DataNinja777
Super User
Super User

Hi @tmrwall ,

 

Since your data table doesn't have a date column, create a Start of Quarter Date using DAX in a calculated column:

Start of Quarter Date = 
DATE(
    'Table'[Year],
    right('Table'[Quarter],1) * 3 - 2,
    1
)

Next, to enable proper time-based filtering, create a Calendar Table using DAX:

Calendar =
ADDCOLUMNS(
    CALENDAR(DATE(2020, 1, 1), DATE(2025, 12, 31)),
    "Year", YEAR([Date]),
    "Quarter", "Q" & FORMAT(CEILING(MONTH([Date]) / 3, 1), "0"),
    "Year-Quarter", FORMAT([Date], "YYYY") & "-Q" & FORMAT(CEILING(MONTH([Date]) / 3, 1), "0")
)

 

DataNinja777_0-1736700660785.png

Then, create a relationship between the tables

Go to Model View in Power BI and:

  1. Connect the Start of Quarter Date in your Sales table to the Date column in the Calendar Table.
  2. Ensure the relationship is one-to-many with the Calendar Table filtering the Sales table.

Now, calculate the Average Unit Price by Quarter using this DAX measure:

Average Unit Price by Quarter =
DIVIDE(
    SUM('Sales'[Amount Paid]),
    SUM('Sales'[Number of units])
)

 

This measure will dynamically adjust based on the filters applied, such as Category <> C.

DataNinja777_1-1736701299566.png

 

I have attached an example pbix file for your reference.

 

Best regards,

 

View solution in original post

Anonymous
Not applicable

Hi @tmrwall ,

 

According to your screenshot, I am confused about the [Average Unit Price] after 2023-Q1. I think the [Average Unit Price] should be calculated by dividing [Amount Paid] by [Number of units]. However, in your screenshot, it shows 9 in 2023 Q2.

As far as I know, calculated column couldn't be dynamic.
If you want to get dynamic result by filter, I suggest you to try to create a measure. 

 

Measure = 
DIVIDE(SUM('Table'[Amount Paid]),SUM('Table'[Number of units]))

 

Result is as below.

vrzhoumsft_0-1736839886492.png

 

Best Regards,
Rico Zhou

 

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

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @tmrwall ,

 

According to your screenshot, I am confused about the [Average Unit Price] after 2023-Q1. I think the [Average Unit Price] should be calculated by dividing [Amount Paid] by [Number of units]. However, in your screenshot, it shows 9 in 2023 Q2.

As far as I know, calculated column couldn't be dynamic.
If you want to get dynamic result by filter, I suggest you to try to create a measure. 

 

Measure = 
DIVIDE(SUM('Table'[Amount Paid]),SUM('Table'[Number of units]))

 

Result is as below.

vrzhoumsft_0-1736839886492.png

 

Best Regards,
Rico Zhou

 

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

 

 

DataNinja777
Super User
Super User

Hi @tmrwall ,

 

Since your data table doesn't have a date column, create a Start of Quarter Date using DAX in a calculated column:

Start of Quarter Date = 
DATE(
    'Table'[Year],
    right('Table'[Quarter],1) * 3 - 2,
    1
)

Next, to enable proper time-based filtering, create a Calendar Table using DAX:

Calendar =
ADDCOLUMNS(
    CALENDAR(DATE(2020, 1, 1), DATE(2025, 12, 31)),
    "Year", YEAR([Date]),
    "Quarter", "Q" & FORMAT(CEILING(MONTH([Date]) / 3, 1), "0"),
    "Year-Quarter", FORMAT([Date], "YYYY") & "-Q" & FORMAT(CEILING(MONTH([Date]) / 3, 1), "0")
)

 

DataNinja777_0-1736700660785.png

Then, create a relationship between the tables

Go to Model View in Power BI and:

  1. Connect the Start of Quarter Date in your Sales table to the Date column in the Calendar Table.
  2. Ensure the relationship is one-to-many with the Calendar Table filtering the Sales table.

Now, calculate the Average Unit Price by Quarter using this DAX measure:

Average Unit Price by Quarter =
DIVIDE(
    SUM('Sales'[Amount Paid]),
    SUM('Sales'[Number of units])
)

 

This measure will dynamically adjust based on the filters applied, such as Category <> C.

DataNinja777_1-1736701299566.png

 

I have attached an example pbix file for your reference.

 

Best regards,

 

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