Forum Discussion
Use FIRSTNONBLANK() with String and Date
- 4 years ago
Hi sanaankbar56,
I was very clear with your requirement and I have tested it as below.
from above table, the "FirstRetnFruit" is the measure for for it.
The code is as I showed at my previous answer.
Hope this helps you. Thanks
Hi sanaankbar56,
I was very clear with your requirement and I have tested it as below.
from above table, the "FirstRetnFruit" is the measure for for it.
The code is as I showed at my previous answer.
Hope this helps you. Thanks
- sananakbar564 years agoFrequent Visitor
Thankyou for responding. Yes, that brings me very close but I think this is not factoring in the Transaction Type column. Currently, it is taking the first product purchased by each customer and returning that. What I am looking for is the first time there was a Return flag (Transaction Type = Return ) for each customer.
I think another dataset which represents this problem is below and the FirstReturnProduct Column is what I want.
CustomerID Purchase TransactionType TransactionDate FirstReturnProduct 1 Melons NULL 1/1/2021 Bananas 1 Bananas Return 1/2/2021 Bananas 1 Bananas NULL 1/3/2021 Bananas 1 Apples NULL 1/4/2021 Bananas 1 Apples Return 1/5/2021 Bananas 2 Avocado NULL 1/6/2021 Peaches 2 Peaches Return 1/7/2021 Peaches 2 Oranges Return 1/8/2021 Peaches 2 Oranges NULL 1/9/2021 Peaches - sananakbar564 years agoFrequent Visitor
It worked now. We were missing one filter.
FirstReturnProduct =
CALCULATE(FIRSTNONBLANKVALUE(Fruits[TransactionDate],SELECTEDVALUE( fruits[Purchase] )),ALLEXCEPT( Fruits, Fruits[CustomerID] ), Fruits[TransactipnType] = "Return")Thanks a lot for your help. I have accepted this as solution.