Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
I am trying to create a column that displays the previous rows data, but is grouped by both a category column and date column. Right now I have something like this:
I would like to see results like this:
So the amount from the earlier line based on the area and date appears in the new column. Note that the date is not consecutive as the data is collected at the month end. Is there a way I can accomplish this using DAX?
Solved! Go to Solution.
Hi, @scorbin-j
You can try the following methods.
Previous =
Var _Prevdate=MAXX(FILTER('Table',[Date]<EARLIER('Table'[Date])&&[Area]=EARLIER('Table'[Area])),[Date])
Return
CALCULATE(SUM('Table'[Amount]),FILTER('Table',[Date]=_Prevdate&&[Area]=EARLIER('Table'[Area])))
Is this the result you expect?
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, @scorbin-j
You can try the following methods.
Previous =
Var _Prevdate=MAXX(FILTER('Table',[Date]<EARLIER('Table'[Date])&&[Area]=EARLIER('Table'[Area])),[Date])
Return
CALCULATE(SUM('Table'[Amount]),FILTER('Table',[Date]=_Prevdate&&[Area]=EARLIER('Table'[Area])))
Is this the result you expect?
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.
That seems to be working! Thank you so much
So I have a partial solution. I created an index column like this:
IndexColumn =
RANKX(
ALL(Amounts),
Amounts[Date],,
ASC,
Dense
)
PrevRowEmpCount =
CALCULATE(
'Measure'[SUMAmounts],
TOPN(
1,
FILTER(
ALLSELECTED('Amounts'),
Amounts[Date] < MAX(Amounts[Date])
),
Amounts[Date],
DESC
)
)
OK. I see the problem now. I'm not sure how to implement it as a column.
Good luck.
Hi @scorbin-j
Try this
Previous Amount =
VAR _Area = SELECTEDVALUE( 'Area Amounts'[Area] )
VAR _CurrDt = SELECTEDVALUE( 'Area Amounts'[Date] )
VAR _PrevDt =
CALCULATE(
MAX( 'Area Amounts'[Date] ),
FILTER(
ALL( 'Area Amounts' ),
'Area Amounts'[Area] = _Area
&& 'Area Amounts'[Date] < _CurrDt
)
)
VAR _PrevAmt =
CALCULATE(
SUM( 'Area Amounts'[Amount] ),
FILTER(
ALL( 'Area Amounts' ),
'Area Amounts'[Area] = _Area
&& 'Area Amounts'[Date] = _PrevDt
)
)
RETURN
_PrevAmt
Tried that out and right now that is just outputting blank values in the new column it created.
Oops. My mistake. I built that as a measure.
If you're interested...
https://1drv.ms/u/s!AnF6rI36HAVkhPIouUq80dpJUlOV5w?e=XUbYYb
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
123 | |
78 | |
49 | |
38 | |
37 |
User | Count |
---|---|
196 | |
80 | |
70 | |
51 | |
42 |