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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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