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
Anonymous
Not applicable

average in column per month

Hi Dear,

I have a question avout average.

I have 2 tables A & B.

In both tables, I have Date Column and Cost Column

Table A can have many row per month but table B have one row per month

In table A, I want to calcutate average of cost of table B like cost B divide by number of item per month (for the same month ) in table B and return in each row the average cost of month.

 

e.g : if average cost (cost B/Number of item A) is 17€ for April 2022, in my new colum in table A, for each row the value must be 17€. *

So if 170€ (table B) for 10 rows (table A), in table A, 17€ for each rows

So it's like a distribution of cost B to all rows of table A for same month

 

Thanks you for fyour help.

Wilfried.

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, here's my solution.

Create a calculated column.

Column =
VAR _B =
    MAXX (
        FILTER (
            'Table B',
            MONTH ( 'Table B'[Date] ) = MONTH ( EARLIER ( 'Table A'[Date] ) )
        ),
        'Table B'[Cost]
    )
VAR _Count =
    COUNTROWS (
        FILTER (
            'Table A',
            MONTH ( 'Table A'[Date] ) = MONTH ( EARLIER ( 'Table A'[Date] ) )
        )
    )
RETURN
    DIVIDE ( _B, _Count )

Get the expected result.

vkalyjmsft_0-1653358187351.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, here's my solution.

Create a calculated column.

Column =
VAR _B =
    MAXX (
        FILTER (
            'Table B',
            MONTH ( 'Table B'[Date] ) = MONTH ( EARLIER ( 'Table A'[Date] ) )
        ),
        'Table B'[Cost]
    )
VAR _Count =
    COUNTROWS (
        FILTER (
            'Table A',
            MONTH ( 'Table A'[Date] ) = MONTH ( EARLIER ( 'Table A'[Date] ) )
        )
    )
RETURN
    DIVIDE ( _B, _Count )

Get the expected result.

vkalyjmsft_0-1653358187351.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

Anonymous
Not applicable

Additionnal information : draft

templatetemplate

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.