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


Go to My LinkedIn Page


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.


Go to My LinkedIn Page


This works @Jihwan_Kim 

Thank you very much.

Regards
Ron

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.