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.
Hi All,
I have below data and I need to get % diff for current row and previous row and also show first row as 0 if there is no previous row.
Here my year column is in string datatype.
Solved! Go to Solution.
Hi @NaiduNaidu ,
Ypu can achieve your goal following these steps:
1- Create a new calculated column for sortYear using this DAX:
SortYear = VALUE(SUBSTITUTE('Table'[Year], "F", ""))
2- Now create a new measure for % Diff by this DAX:
% Diff =
VAR CurrentSales = MAX('Table'[Sales])
VAR CurrentYear = MAX('Table'[SortYear])
VAR PreviousSales =
CALCULATE(
MAX('Table'[Sales]),
FILTER(
ALL('Table'),
'Table'[SortYear] = CurrentYear - 1
)
)
RETURN
IF(
ISBLANK(PreviousSales),
0,
DIVIDE(CurrentSales - PreviousSales, PreviousSales)
)
3- Now drag and drop the % Diff measure for your Matrix, your result will look like this:
Hi @NaiduNaidu ,
Ypu can achieve your goal following these steps:
1- Create a new calculated column for sortYear using this DAX:
SortYear = VALUE(SUBSTITUTE('Table'[Year], "F", ""))
2- Now create a new measure for % Diff by this DAX:
% Diff =
VAR CurrentSales = MAX('Table'[Sales])
VAR CurrentYear = MAX('Table'[SortYear])
VAR PreviousSales =
CALCULATE(
MAX('Table'[Sales]),
FILTER(
ALL('Table'),
'Table'[SortYear] = CurrentYear - 1
)
)
RETURN
IF(
ISBLANK(PreviousSales),
0,
DIVIDE(CurrentSales - PreviousSales, PreviousSales)
)
3- Now drag and drop the % Diff measure for your Matrix, your result will look like this:
You can try "Visual calculations".
For that select "..." on the table right top corner, select "Visual calculations" and "Versus Previous".
In popped up formula, indicate "Sales" column.
Hi @NaiduNaidu
You can use Offset function to get a desired result :
The pbix is attached
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
145 | |
87 | |
66 | |
51 | |
45 |
User | Count |
---|---|
215 | |
90 | |
83 | |
66 | |
58 |