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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
LWJ2019
New Member

Average function causing measure calculation out of desired date period

Hi, 

I have issue with below measure.

I need to calculate the average within the date range but whenver i use AVERAGE function, it doesn't work!

How can i modify below measure?

 

AVGCCSA_Q =
VAR SelectedYearMonth = SELECTEDVALUE('Slicer'[YYYYMM])
VAR _seldatenum =
    CALCULATE (
        MAX('FactFINData'[Dnum]),
        FILTER (
            ALLSELECTED('FactFINData'),
            'FactFINData'[YYYYMM] = SelectedYearMonth
        )
    )
VAR _startDNum = _seldatenum -
    SWITCH(
        INT(RIGHT(_seldatenum, 2)),
        10, 100,
        11, 101,
        12, 102,
        1, 191,
        2, 192,
        3, 193,
        4, 194,
        5, 195,
        6, 196,
        7, 197,
        8, 198,
        9, 199,
        0  
    )
VAR _endDNum = _seldatenum -
    SWITCH(
        INT(RIGHT(_seldatenum, 2)),
        10, 1,
        11, 2,
        12, 3,
        1, 92,
        2, 93,
        3, 94,
        4, 95,
        5, 96,
        6, 97,
        7, 98,
        8, 99,
        9, 100,
        0 
    )
RETURN
CALCULATE (
        AVERAGE ( DimSalesPercentage[SalesAmountCC] ),
        DimSalesPercentage[cost_ctr] = SELECTEDVALUE ( FactFINData[cost_ctr] ),
        FILTER (
            ALL('FactFINData'[DNum]),
            'FactFINData'[DNum] >= _startDNum &&
            'FactFINData'[DNum] <= _endDNum
        )
    )
       
2 REPLIES 2
LWJ2019
New Member

Issue solved.

Hi @LWJ2019 

 

Glad that you have solved the issue. If possible, can you share your solution with the community so that other people who have similar issues in the future will benefit from it. Thank you!

 

Best Regards,
Jing

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Solution Authors