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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
PowerRon
Post Patron
Post Patron

DAX : Only show average sale per year on year level

Hi

this is my matrix and I only want to to show Yearly Avg Per Day on the year level.
Knipsel.JPG

 

I created two measures (see below), but both don't give the desired result. What am I doing wrong

Yearly Avg Per Day 2 =
IF(
    --ISINSCOPE('Calendar'[Date].[Year]),
    ISFILTERED('Calendar'[Date].[Year]),
AVERAGEX(
    CALCULATETABLE(
        VALUES('Calendar'[Date]),
        ALL('Calendar'        ),
        'Calendar'[CalendarYear]=MAX('Calendar'[CalendarYear])
    ),
    [Total Sales]
),
BLANK()
)



Yearly Avg Per Day 3 =
VAR _average =
AVERAGEX(
    CALCULATETABLE(
        VALUES('Calendar'[Date]),
        ALL('Calendar'        ),
        'Calendar'[CalendarYear]=MAX('Calendar'[CalendarYear])
    ),
    [Total Sales]
)
RETURN
SWITCH(TRUE(),
ISINSCOPE('Calendar'[Date].[Year]),_average,
BLANK()
)
 
Regards

@v-yueyunzh-msft  , do you have any idea?
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

I tried to create a sample pbix file like below.

 

Jihwan_Kim_0-1676798605120.png

 

Jihwan_Kim_1-1676798617513.png

 

Sales avg per year: =
VAR _currentyear =
    MAX ( 'Calendar'[Year] )
RETURN
    SWITCH (
        TRUE (),
        ISINSCOPE ( 'Calendar'[Month] ), BLANK (),
        ISINSCOPE ( 'Calendar'[Qtr] ), BLANK (),
        ISINSCOPE ( 'Calendar'[Year] ),
            AVERAGEX (
                ADDCOLUMNS (
                    FILTER ( ALL ( 'Calendar' ), 'Calendar'[Year] = _currentyear ),
                    "@sales", CALCULATE ( SUM ( Data[Sales] ) )
                ),
                [@sales]
            )
    )

 

 

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

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

I tried to create a sample pbix file like below.

 

Jihwan_Kim_0-1676798605120.png

 

Jihwan_Kim_1-1676798617513.png

 

Sales avg per year: =
VAR _currentyear =
    MAX ( 'Calendar'[Year] )
RETURN
    SWITCH (
        TRUE (),
        ISINSCOPE ( 'Calendar'[Month] ), BLANK (),
        ISINSCOPE ( 'Calendar'[Qtr] ), BLANK (),
        ISINSCOPE ( 'Calendar'[Year] ),
            AVERAGEX (
                ADDCOLUMNS (
                    FILTER ( ALL ( 'Calendar' ), 'Calendar'[Year] = _currentyear ),
                    "@sales", CALCULATE ( SUM ( Data[Sales] ) )
                ),
                [@sales]
            )
    )

 

 

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.

This works @Jihwan_Kim 

Thank you very much.

Regards
Ron

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors