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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Prasanthh60
Regular Visitor

Create an Average row in matrix.

Hi All,

 

Thanks in advance. The following is where I am at when I try to design a custom dashboard.

 

I used data from three sources to build a matrix table. Under the total row, I also require an average row, so that I may see the daily average. The July month data will be in day-wise format if I drilldown.

 

Prasanthh60_0-1729265545018.png

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, 

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

Jihwan_Kim_1-1729319219556.png

 

 

Jihwan_Kim_0-1729319184209.png

 

 

expected result: = 
VAR _sum =
    SUM ( data_fact[value] )
VAR _total =
    CALCULATE ( SUM ( data_fact[value] ), ALL ( matrix_dim ) )
VAR _monthlyaverage =
    AVERAGEX (
        ALL ( matrix_dim[Year-Month sort number], matrix_dim[Year-Month] ),
        CALCULATE ( SUM ( data_fact[value] ) )
    )
RETURN
    SWITCH (
        SELECTEDVALUE ( matrix_dim[Year-Month] ),
        "Total", _total,
        "Average", _monthlyaverage,
        _sum
    )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

4 REPLIES 4
Prasanthh60
Regular Visitor

Thanks for responding. Actually, i need avg influx, avg production, avg target per day. The July month data is Day wise data. If i drill down, I can see all the daywise data. 

Hence, I need an per day avg of the Month. 

Jihwan_Kim
Super User
Super User

Hi, 

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

Jihwan_Kim_1-1729319219556.png

 

 

Jihwan_Kim_0-1729319184209.png

 

 

expected result: = 
VAR _sum =
    SUM ( data_fact[value] )
VAR _total =
    CALCULATE ( SUM ( data_fact[value] ), ALL ( matrix_dim ) )
VAR _monthlyaverage =
    AVERAGEX (
        ALL ( matrix_dim[Year-Month sort number], matrix_dim[Year-Month] ),
        CALCULATE ( SUM ( data_fact[value] ) )
    )
RETURN
    SWITCH (
        SELECTEDVALUE ( matrix_dim[Year-Month] ),
        "Total", _total,
        "Average", _monthlyaverage,
        _sum
    )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Thnank you. I have not tried writing this complex formulas in POwer bi. I will try with the above.

pborah
Impactful Individual
Impactful Individual

Can I ask what the interpretation of the average in the context of a row would be? Like you want to know average Influx, Production, etc per day for July and perhaps each month? 

 

Because on a monthly roll up, if you have the total, average for July kinda loses meaning. But if you say for the whole year on average the Influx or Production was x units per month, that makes more sense in terms of valuable business information. 

 

You might benefit more from transposing your matrix where the months are in columns and your product heirarchy is in rows.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.