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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
NOVICE02
Helper III
Helper III

Calculating Weighted average from transactional data

Hi all, 

This is a first for me. I have looked at the other solutions and still can't figure it out.

 

I have transactiona data like below (note there are 20+ variables). I need to calculate the weighted average of the balance and i want to show it for different segment types if possible... ie. by class or by month & class and so forth

 

 

IDClassBalanceDate
1mm733.662021-11-02
2h1742.482021-11-02
3ll726.652021-11-02
4lr680.052021-11-02
5ll1405.362021-11-02
6mr904.082021-11-02
7ml387.542021-11-02
8h549.252021-11-02
9hl1124.72021-11-02
10hr444.312021-11-02

 

What would be the best way to approach this ? Appreciate any direction on this frequently discussed topic

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

To calculate the weighted average according to different segment types, you may need to create multiple measures.

The measure I created is calculated according to class.

WA Sales by Product = 
VAR AnnualSales =
    CALCULATE(
        SUM('Table (2)'[Balance]),
        ALL('Table (2)'[Class])
    )
VAR SummarisedTable =
    ADDCOLUMNS(
        SUMMARIZE(
            'Table (2)','Table (2)'[Class],'Table (2)'[Date].[Year]
            
        ),
        "SalesWt", SUM('Table (2)'[Balance]) / AnnualSales,
        "Sales", SUM('Table (2)'[Balance])
    )
RETURN
    SUMX(
        SummarisedTable,
        [SalesWt] * [Sales]
    )

 

View solution in original post

2 REPLIES 2
V-lianl-msft
Community Support
Community Support

To calculate the weighted average according to different segment types, you may need to create multiple measures.

The measure I created is calculated according to class.

WA Sales by Product = 
VAR AnnualSales =
    CALCULATE(
        SUM('Table (2)'[Balance]),
        ALL('Table (2)'[Class])
    )
VAR SummarisedTable =
    ADDCOLUMNS(
        SUMMARIZE(
            'Table (2)','Table (2)'[Class],'Table (2)'[Date].[Year]
            
        ),
        "SalesWt", SUM('Table (2)'[Balance]) / AnnualSales,
        "Sales", SUM('Table (2)'[Balance])
    )
RETURN
    SUMX(
        SummarisedTable,
        [SalesWt] * [Sales]
    )

 

amitchandak
Super User
Super User

@NOVICE02 , What is the expected value.

 

You can try a measure like

divide(sum(Table[Balance]), count(Table[Balance]))

Helpful resources

Announcements
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.