Forum Discussion
Formula to compare previous cells
- 5 years ago
Hi, AGonza123
Please check the below picture and the measure below, which are for creating a measure.
The link to the sample pbix file is down below.
https://www.dropbox.com/s/6s2vcied9g2blg4/agonza.pbix?dl=0
Result =VAR currentenddate =MAX ( 'Table'[End Date] )VAR enddatepreviousrow =CALCULATE (LASTNONBLANK ( 'Table'[End Date], MAX ( 'Table'[End Date] ) ),FILTER ( ALLSELECTED ( 'Table' ), 'Table'[End Date] < currentenddate ))RETURNIF (ISFILTERED ( 'Table' ),IF (SELECTEDVALUE ( 'Table'[Arrival Date] ) <> BLANK ()&& SELECTEDVALUE ( 'Table'[End Date] ) <> BLANK ()&& enddatepreviousrow <> BLANK (),"ok","verify"))Hi, My name is Jihwan Kim.
If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.
Linkedin: linkedin.com/in/jihwankim1975/
Twitter: twitter.com/Jihwan_JHKIM
Hi, AGonza123
Thank you for your message.
Sorry that I quite do not understand your last question.
I don't understand your last measure and I think it is saying a different thing than what you asked before.
Please write like below for your new table.
Or, please let me know how your desired outcome looks like.
-
Hello, thank you very much for your answer, I tried to explain myself better, at the beginning I thought that just showing that example of dates would work but as I have more data it gets complicated, if in power bi with that example of two dates I could already join the columns of my table a with columns of table b creating a new table but I don't know if it is the right thing to do, in the attached link you can find part of the tables and the result of how I hope it can be done, each store has its sku with dates of arrival and finish and what I want to achieve is that by having more than 10 stores united, the formula can perform this logical operation for each point, that is, it only analyzes the relationship of dates corresponding to that point and then the next point analyzes their corresponding dates I hope you understand me
https://drive.google.com/file/d/1cmjEBt4E9Yw97PwLg-Id681B-6qdYvKh/view?usp=sharing
- Jihwan_Kim5 years ago
Super User
Hi, AGonza123
Thank you for your message.
I cannot access your shared file. It asked to enter the password.
Please kindly check.
- AGonza1235 years agoFrequent Visitor
Excuse me, and now could you confirm if I let you enter, both links are the same
- Jihwan_Kim5 years ago
Super User
Hi, AGonza123
Thank you for your message.
Terribly sorry to say that I don't know which part I am missing.
Perhaps I did not check your previous message or comment.
Sorry but please clarify the below.
- The initial equation was, if three cells are not blank, then "OK". But do you want to change it to If three cells are not blank, then "Verify"? Am I correct?
-what is store arrival? -> in which table can I find this column?
-what is store resultable? -> in which table can I find this column?
-what is sku arrival? -> in which table can I find this column?
- AGonza1235 years agoFrequent Visitor
I had not seen your answer, excuse me because I did not express myself correctly, in the file indicate the terms as I mentioned them and with the modified formula indicating the cells, as I had previously commented I have two tables (arrival table and end table) and what I did was join them in power bi to what would be the "resultable" side table (I thought the most convenient) and on that table I would be needing to apply the formula, I hope I have expressed myself better this time, thank you very much!
- Jihwan_Kim5 years ago
Super User
Hi, AGonza123
Thanks for sharing.
Please check the below and the link.
Assumption:
- Sorry that I cannot know how to define the week number. I assume you have your own financial week number, so I matched to your sample.
- Sorry that I cannot differentiate Laureles week10 11th march 12 Q arrival, and Laureles week10 11th march 36 Q arrival. So I aggregated and total Q 48.
- I tried not to create additional table (Result Table). I could create the visualization like below.
- I assumed that you changed the condition of generating "Verify" and "Ok". Please check this, because I am really confusing about this. This makes the whole question different than your very first question and I think this is not the same question as your first question. You may say what is the difference between changing the result from A to B. Then, please ask to get the result A or B, instead of writing a word that has a certain meaning. The opposite meaning of the result drives me to think whether I wrote the DAX measure totally wrong way or not.
- I failed to understand where is the situation that Arrival Date is Blank and at the same time end date is not blank (ingreso sin pedido). I assume you did not share all your data.
Q Arrival =SUM(Arrival[Q])Q End =SUM('End'[Q])Result =IF( ISFILTERED(Dates[WEEK]),SWITCH( TRUE(),[Q Arrival]<> BLANK() && [Q End] <> BLANK(), "Verify",[Q Arrival] = BLANK() && [Q End] = BLANK(), "SQ",[Q Arrival] = BLANK() && [Q End] <> BLANK(), "ingreso sin pedido","OK"))Hi, My name is Jihwan Kim.
If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.
Linkedin: linkedin.com/in/jihwankim1975/
Twitter: twitter.com/Jihwan_JHKIM