Forum Discussion
If based on first date occurrence
- 7 years ago
Anonymous
Try this for the new column:
NewColumn=
VAR _StartDate = CALCULATE ( MIN ( Query1[Start date of service] ), ALLEXCEPT ( Query1, Query1[Product], Query1[Customer] ) )
RETURN
IF( Query1[Start date of service] = _StartDate, "New", "Refill")
Anonymous
Create a Calculated column with following code
Start Date = CALCULATE(MIN(Sheet1[Start]),ALLEXCEPT(Sheet1,Sheet1[Patient ID]))
Create slicer column with following code
Flag = IF(Sheet1[Start]=Sheet1[Start Date],"Start","Refill")
play around with the attached PBIX.
Not sure if I was clear. Need first date for each oder per product per customer
So the new column should be perhaps
- AlB7 years agoCommunity Champion
Anonymous
Then
Start Date = CALCULATE ( MIN ( Query1[Start date of service] ), ALLEXCEPT ( Query1, Query1[Product], Query1[Customer] ) )should suffice for the start date. You can, within the code for the column, check whether the current row date equals the start date.
- AlB7 years agoCommunity Champion
Anonymous
Try this for the new column:
NewColumn=
VAR _StartDate = CALCULATE ( MIN ( Query1[Start date of service] ), ALLEXCEPT ( Query1, Query1[Product], Query1[Customer] ) )
RETURN
IF( Query1[Start date of service] = _StartDate, "New", "Refill")- Anonymous7 years agoNot applicable
That is exactly what I was trying to acheive. Thank You
- Anonymous7 years agoNot applicable
Thank you, that definitely gives me the first "start date" for each product for each patient.
However now, I'm really going to show my newbieness. the if statement shown above seems like it should work comparing the row's start date with the new columns start date, however, when I try to write out the if statement, it is only allowing me to type in measures and not actual column names to compare.
What am I doing wrong, just need to create an if statement that compares start date to the new column???
- itsmebvk7 years agoContinued Contributor
Anonymousdid you try to tweak context as follow?
Start Date = CALCULATE(MIN(Sheet1[Start]),ALLEXCEPT(Sheet1,Sheet1[Patient ID],Sheet1[Part Number]))
- Anonymous7 years agoNot applicable
Thank You that works.
however I've an issue with the if statement. PowerBI is only allowing me to type in measures to do the logical test. not columns, am I doing something wrong?