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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Mseddi
New Member

HELP _ Including measure in calculated column

Hi guys,

 

I have 3 table :
* Sales table including invoice date

* collection table including clearing invoice date, net due date, Collection Period as calculated column (clearing date-Net due date)

* date table with a link between invoice date[sales Table] and clearing date [Collection Table]

 

Objective : for each row in the sales table I want to include average collection period for previous year
example : if in a row of sales table, invoice date is 31-12-2022, I want to get Average collection period for all invoices cleared from 31-12-2022 to 31-12-2021.

Measure should be -> Average collection previous year = CALCULATE(

    AVERAGE('Collection'[Collection Period])
    ,PREVIOUSYEAR ('Sales'[Date invoice]))


base on this measure, how can I include the value in each raw (as calculuted column) in sales table ????

thanks you in advance

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Mseddi 

Please try

Average collection previous year =
VAR InvoiceDate = 'Sales'[Date invoice]
RETURN
AVERAGEX (
FILTER (
'Collection',
'Collection'[Date] <= InvoiceDate
&& 'Collection'[Date] >= InvoiceDate - 365
),
'Collection'[Collection Period]
)

View solution in original post

6 REPLIES 6
tamerj1
Super User
Super User

Hi @Mseddi 

Please try

Average collection previous year =
VAR InvoiceDate = 'Sales'[Date invoice]
RETURN
AVERAGEX (
FILTER (
'Collection',
'Collection'[Date] <= InvoiceDate
&& 'Collection'[Date] >= InvoiceDate - 365
),
'Collection'[Collection Period]
)

If this is being executed as a calculated column, wouldnt the row context restrict the Filter to just that row?

@AnthonyGenovese 

Of course not. This is a No CALCULATE solution which means no context transition. 

Yah, my bad. I was assuming you called a measure & it had an implicit calculate.

Thank you guys so much. It worked.

the X is the key for the solution : Row context. ❤️

AnthonyGenovese
Resolver III
Resolver III

You will need to use ALL/RemoveFilter in your calculate to remove the filter context of the current row you are on.

 

If this post was helpful, please kudos or accept the answer as a solution.
~ Anthony Genovese
Need more PBI help? PM me for affordable, dedicated training or consultant recomendations!

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.