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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jsgambel
Regular Visitor

I need to show year over year values and they should be responsive to filters

Hi all, new to Power BI, so thank you for your help.

 

I need help tweaking my DAX. I have a spreadsheet for a data source. It has a list of clients, years, region, and a measure.

Sample: 

Year1KeyTypeRegionCountDateYear
201020039423BreakawayEUROPE101/01/2010
201020048145StillNORTH AMERICA101/01/2010
201020069080StillEUROPE101/01/2010
201020199484AmbiantEUROPE101/01/2010
201020200079BreakawayEUROPE101/01/2010
201020200128AmbiantASIA101/01/2010
201020200213StillEUROPE101/01/2010
201020200417AmbiantASIA101/01/2010
201020200698GlassASIA101/01/2010
201020200700GlassAUSTRALIA101/01/2010
201020200728BreakawayEUROPE101/01/2010
201020201136BreakawayASIA101/01/2010

 

I want to show Year over Year values. I was able to do this for just the Year (though the Total for my column isn't right):

jsgambel_0-1670363752125.png

The column definition:

 

zPrevYearCount3 = 
VAR PriorYear = MAX('Sheet1'[Open Year]) -1
VAR Result = 
    SUMX(
        FILTER(
            ALL(Sheet1),
            'Sheet1'[Open Year] = PriorYear
        ),
        'Sheet1'[Count]
    )
RETURN
    Result

 

 

But, when I add the Region in, the results aren't right:

jsgambel_2-1670363988192.png

 

This isn't actually the ideal way I want to present it. I want to put the years across the top and Region/other attributes down the side, but I can't even get this to work (I assume this is easier like this rather than my preferred way). Thanks.

 

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @jsgambel 

 

Column:

zPrevYearCount3 =
VAR PriorYear =
    MAX ( 'Sheet1'[Open Year] ) - 1
VAR Result =
    SUMX (
        FILTER (
            ALL ( Sheet1 ),
            'Sheet1'[Open Year] = PriorYear
                && [Region] = EARLIER ( 'Sheet1'[Region] )
        ),
        'Sheet1'[Count]
    )
RETURN
    Result

Measure:

zPrevYearCount3 =
VAR PriorYear =
    MAX ( 'Sheet1'[Open Year] ) - 1
VAR Result =
    SUMX (
        FILTER (
            ALL ( Sheet1 ),
            'Sheet1'[Open Year] = PriorYear
                && [Region] = SELECTEDVALUE ( 'Sheet1'[Region] )
        ),
        'Sheet1'[Count]
    )
RETURN
    Result

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-zhangti
Community Support
Community Support

Hi, @jsgambel 

 

Column:

zPrevYearCount3 =
VAR PriorYear =
    MAX ( 'Sheet1'[Open Year] ) - 1
VAR Result =
    SUMX (
        FILTER (
            ALL ( Sheet1 ),
            'Sheet1'[Open Year] = PriorYear
                && [Region] = EARLIER ( 'Sheet1'[Region] )
        ),
        'Sheet1'[Count]
    )
RETURN
    Result

Measure:

zPrevYearCount3 =
VAR PriorYear =
    MAX ( 'Sheet1'[Open Year] ) - 1
VAR Result =
    SUMX (
        FILTER (
            ALL ( Sheet1 ),
            'Sheet1'[Open Year] = PriorYear
                && [Region] = SELECTEDVALUE ( 'Sheet1'[Region] )
        ),
        'Sheet1'[Count]
    )
RETURN
    Result

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks @v-zhangti . The measure worked for me. I'll use the column if/when I need it.

Greg_Deckler
Community Champion
Community Champion

@jsgambel Try:

zPrevYearCount3 = 
VAR PriorYear = MAX('Sheet1'[Open Year]) -1
VAR Result = 
    SUMX(
        FILTER(
            ALLEXCEPT(Sheet1,[Region]),
            'Sheet1'[Open Year] = PriorYear
        ),
        'Sheet1'[Count]
    )
RETURN
    Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks for the reply @Greg_Deckler 

 

I had to make one small change to make it work: 

ALLEXCEPT(Sheet1,Sheet1[Region]),
 
But, the result for this one is the same as the original.

@jsgambel It's hard to replicate with the given sample data since it only includes a single year.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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