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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
lukasss
New Member

How to calculate month averages when there are days without values

Hello comunity,

I've searched my answer online but couldn't find a sollution.

My goal is to calculate average page views per month including all days in a given month.

The Avg below shows 1.5 but it doesn't ake into consideration days without any page views. However,  I need 12/31(days) = 0.4.

I have a dimension date table linking my page views table. How do I divide page views by all days in a gien month? 

Capture.PNG

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

Hi @lukasss ,

According to your description, here's my solution. Create a measure.

Average =
VAR _SUM =
    SUMX (
        FILTER (
            ALL ( 'Page views' ),
            MONTH ( 'Page views'[Date] ) = MONTH ( MAX ( 'Page views'[Date] ) )
        ),
        'Page views'[PageViews]
    )
VAR _DAYS =
    COUNTROWS (
        FILTER (
            ALL ( 'Date' ),
            MONTH ( 'Date'[Date] ) = MONTH ( MAX ( 'Page views'[Date] ) )
        )
    )
RETURN
    DIVIDE ( _SUM, _DAYS )

Get the correct result:

vyanjiangmsft_0-1685697025901.png

I attach my sample below for your reference.

 

Best regards,

Community Support Team_yanjiang

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

1 REPLY 1
v-yanjiang-msft
Community Support
Community Support

Hi @lukasss ,

According to your description, here's my solution. Create a measure.

Average =
VAR _SUM =
    SUMX (
        FILTER (
            ALL ( 'Page views' ),
            MONTH ( 'Page views'[Date] ) = MONTH ( MAX ( 'Page views'[Date] ) )
        ),
        'Page views'[PageViews]
    )
VAR _DAYS =
    COUNTROWS (
        FILTER (
            ALL ( 'Date' ),
            MONTH ( 'Date'[Date] ) = MONTH ( MAX ( 'Page views'[Date] ) )
        )
    )
RETURN
    DIVIDE ( _SUM, _DAYS )

Get the correct result:

vyanjiangmsft_0-1685697025901.png

I attach my sample below for your reference.

 

Best regards,

Community Support Team_yanjiang

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

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.