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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ANP
Frequent Visitor

Is it possible to calculate change from previous column in a matrix

I have data source like below

Month-YearTeamValue
Jul-2023A1.2
Aug-2023A1.4
Jul-2023B2.2
Aug-2023B2.1
and so on  

output I want

 

TeamJul-23Aug-23Diff
A1.21.40.2
B2.22.1-0.1

How I can calculate Diff, I dont have and dont need any date table so no point of mentioning time intelligence solution. How can I calculate Diff Column. I tried having index on rows like below

Month-YearTeamValueIndex
Jul-2023A1.21
Aug-2023A1.42
Jul-2023B2.21
Aug-2023B2.12
and so on   

and the measure like Diff = Table[Value] - Average(Table[Value]{Index-1}) but it gives some cyclic reference issue as index is getting repeated and team is not referenced in formula I guess. Please help

2 ACCEPTED SOLUTIONS

@ANP 

it's better to have a date table to use  time intelligence solution.

if not, you can change the first column to date type

11.PNG

then create a column

Column = 
VAR _LAST=MAXX(FILTER('Table','Table'[Team]=EARLIER('Table'[Team])&&'Table'[Month-Year]=EDATE(EARLIER('Table'[Month-Year]),-1)),'Table'[Value])
RETURN IF(ISBLANK(_LAST),BLANK(),'Table'[Value]-_LAST)

12.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

@ANP 

pls see this

Measure = 
VAR _count=CALCULATE(count('Table'[Column]),ALLSELECTED('Table'[Month-Year]),'Table'[Column]<0)
return if(ISBLANK(_count),"y","n")




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

11 REPLIES 11
ryan_mayu
Super User
Super User

will your request change in the future? currenly, the diff is between jul and aug. will the calculation of diff change in the future?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ANP
Frequent Visitor

HI, Yes this is just example.. months will keep on increasing in data table when i refresh data source on 1st of every month last month-year will be added with a value hence I will require all differences ( Aug-Jul, Sep-Aug, Nov-Oct and so forth) .. there are around 10-12 teams for this data would be added for everymonth.

@ANP 

it's better to have a date table to use  time intelligence solution.

if not, you can change the first column to date type

11.PNG

then create a column

Column = 
VAR _LAST=MAXX(FILTER('Table','Table'[Team]=EARLIER('Table'[Team])&&'Table'[Month-Year]=EDATE(EARLIER('Table'[Month-Year]),-1)),'Table'[Value])
RETURN IF(ISBLANK(_LAST),BLANK(),'Table'[Value]-_LAST)

12.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ANP
Frequent Visitor

Hmm.. looks like thats the only way I had to add a date table... Many thanks Ryan.. however I have one more query if you can help.. month on month is working fine..  if I have to show a column of improvement values as 'Y' and "N" in the end..  lets say if any of the value Aug-Jul, Sep-Aug, Oct-Sep, Nov-Oct is coming as negative then final improvement column will have value N else Y.....

all the difference is negavie then shows "n", else show "Y"?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ANP
Frequent Visitor

for Y all the differences has to be positive .. if any one is negative then 'N'.. Also It should work with the months filter ( lets say I do it for Q2 then only Apr, May , June months will be shown and the calculation above should only done for these months )

@ANP 

pls see this

Measure = 
VAR _count=CALCULATE(count('Table'[Column]),ALLSELECTED('Table'[Month-Year]),'Table'[Column]<0)
return if(ISBLANK(_count),"y","n")




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ANP
Frequent Visitor

wow.. that was simple.. Thanks Ryan..🙏 .. ..  I am showing the final output in 'Matrix' type chart ...by this way I was able to show mom improvement (the improvement measure you created I added as value in matrix chart hence showing for each month as that is the column) but cluless how can I show 'Always improving' as separate column in 'matrix' chart or do you suggest any other chart type( last column in below image ).. lets say there are three months I selected in filter, in that if all the month improvements are Y then Y else  N .. sorry if I am being too demanding ..

 

ANP_3-1701696531686.png

 

 

 

sry ,i don't know how to display like this. it's a matrx + table. Maybe let's see if anyone else can help you on this.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ANP
Frequent Visitor

np.. Ryan thanks a lot for your help

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.