Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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:
Year1 | Key | Type | Region | Count | DateYear |
2010 | 20039423 | Breakaway | EUROPE | 1 | 01/01/2010 |
2010 | 20048145 | Still | NORTH AMERICA | 1 | 01/01/2010 |
2010 | 20069080 | Still | EUROPE | 1 | 01/01/2010 |
2010 | 20199484 | Ambiant | EUROPE | 1 | 01/01/2010 |
2010 | 20200079 | Breakaway | EUROPE | 1 | 01/01/2010 |
2010 | 20200128 | Ambiant | ASIA | 1 | 01/01/2010 |
2010 | 20200213 | Still | EUROPE | 1 | 01/01/2010 |
2010 | 20200417 | Ambiant | ASIA | 1 | 01/01/2010 |
2010 | 20200698 | Glass | ASIA | 1 | 01/01/2010 |
2010 | 20200700 | Glass | AUSTRALIA | 1 | 01/01/2010 |
2010 | 20200728 | Breakaway | EUROPE | 1 | 01/01/2010 |
2010 | 20201136 | Breakaway | ASIA | 1 | 01/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):
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:
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.
Solved! Go to Solution.
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.
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.
@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
Thanks for the reply @Greg_Deckler
I had to make one small change to make it work:
@jsgambel It's hard to replicate with the given sample data since it only includes a single year.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
19 | |
14 | |
13 | |
11 | |
8 |