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

Rolling Average Invoice Cost Based on Number of Invoices

Hi, 

 

I'm struggling to find an answer to an issue that i have.

I am trying to get out the last 5 invoices by supplier down to an itemised level (by date), to calculate an average cost on the item for those last 5 invoices.

The Invoice dates ranks back to 2009, but i cannot just take invoices from say this year as i might not have bought something for 18 months etc.

I've also attached a link to some more Data.

https://www.dropbox.com/l/scl/AACHeYibKkWAnRxJTe5cW6aiJPgsZLUr6Dc

 

This is the Data i have:

 Capture.PNG

 

 

This is the data i would like, by supplier and by item within that supplier.

 

Capture2.PNG

Any help on this would be appreciated.

Thanks

Peter

1 ACCEPTED SOLUTION

@PeterL1

 

Try this MEASURE

 

Sum Value =
CALCULATE (
    SUM ( TableName[NET_VALUE] ),
    TOPN ( 5, TableName, TableName[INVOICE DATE], DESC )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @PeterL1,

 

I cant access to sharing file, I think you need to check the settings.

 

You can follow below steps to if they suitable for your requirement:

1. Create table visual.

2. Add 'Supplier Id' and 'Item ID' column to table visual as group columns.

3. Add QTY and 'NET_VALUE' columns to visual with summary mode 'SUM'.

4. Write a measure to get average and drag to table visual.

AVERAGE =
DIVIDE ( SUM ( Table['NET_VALUE'] ), SUM ( TABLE[QTY] ), 0 )

 

If above not help, please share sample data for test.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft

 

https://www.dropbox.com/s/t0hm8itfxd3bajf/Table1.xlsx?dl=0

 

I've attached another link, hopefully this one will work.

 

The calculation that you have written are fine for all the invoices, however i only want the last 5 invoices relating to each supplier and to ignore any previous invoice in the calculation (which is where i am struggling).

 

Thanks

Peter

 

 

 

 

@PeterL1

 

Try this MEASURE

 

Sum Value =
CALCULATE (
    SUM ( TableName[NET_VALUE] ),
    TOPN ( 5, TableName, TableName[INVOICE DATE], DESC )
)

Regards
Zubair

Please try my custom visuals

Hi @Zubair_Muhammad

 

Thats it !

 

Thanks for the quick reply

 

Peter

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.