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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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.

Anonymous
Not applicable

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.