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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.