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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Till__
Helper I
Helper I

XYZ Analysis matching to a calendar

Dear all, I want to calculate an XYZ Analysis. This works quite fine, but in months where I do not sell a Artikel I do not have an entry conected to a date as it is not sold. But for my analysis I want this month to be counted with zero so that it is included into my Standard Deviation as well as in my average calculation. I was trying to circumvent the problem by matching the Artikel to a clalendar. 


XYZ Variation  =
VAR CalcTable =
    ADDCOLUMNS(
        CROSSJOIN(
            SUMMARIZE('Calendar', 'Calendar'[Year & Month (YYYY-MM)]),
            SUMMARIZE('Umsatz', 'Umsatz'[Artikel])
        ),
        "QuantityByMonth",
        CALCULATE(
            SUMX(
                Umsatz,
                COALESCE(Umsatz[UmsatzStück], 0)
            ),
            FILTER(
                Umsatz,
                Umsatz[Artikel] = EARLIER(Umsatz[Artikel]) &&
                YEAR(Umsatz[Zeit_Tag]) = LEFT(EARLIER('Calendar'[Year & Month (YYYY-MM)]), 4) &&
                MONTH(Umsatz[Zeit_Tag]) = RIGHT(EARLIER('Calendar'[Year & Month (YYYY-MM)]), 2)
            )
        )
    )
VAR Variation =
    DIVIDE(
        STDEVX.P(CalcTable, [QuantityByMonth]),
        AVERAGEX(CalcTable, [QuantityByMonth])
    )


Thank you all in advance! 
1 REPLY 1
Till__
Helper I
Helper I

This code works for all the month the product has been sold but this is giving me a bias. Also the COALESCE(Umsatz[UmsatzStück], 0) does not help as the entry does not exist and is not blank. 

XYZ Variation =
VAR CalcTable =
    ADDCOLUMNS (
        SUMMARIZE ( 'Umsatz', Umsatz[Artikel],'Calendar'[Year & Month (YYYY-MM)]),
        "QuantityByMonth", CALCULATE ( SUMX( Umsatz, COALESCE(Umsatz[UmsatzStück], 0) ) )
    )
VAR Variation =
    DIVIDE (
        STDEVX.S ( CalcTable, [QuantityByMonth] ),
        AVERAGEX ( CalcTable, [QuantityByMonth] )
    )
RETURN
    IF (
        ISBLANK ( Variation ),
        BLANK (),
        IF ( Variation = 0, 1, Variation )
    )

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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