Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I am hoping someone could help.
I have a table that contains product ID (numerous different products) and Transaction Date
I want to be able to identify the First Date a product was bought and the Last Date a product was bought.
I thought the best way to achieve this was to identify how many times that product appeared. I have this formula, it counts duplicates of Product ID as a sequence.
Count of Dups = CALCULATE(COUNTROWS(Table), ALLEXCEPT(Table, Table[ProductID]), EARLIEST(Table[Index]) >= Table[Index])
I tried to sort my table from oldest to newest and the first instance of a ProductID should be labelled as 1. However for some reason that didn’t seem to work and a newer instance was selected.
As for getting the last date a product was sold, I have no idea how to tackle this.
Any help would be appreciated and thanks in advance
Boycie92
Solved! Go to Solution.
Could put this in one column, but is easier to see in three:
Earlier has the rank from earliest (1) to latest (N), Latest is reversed.
Earlier = CALCULATE(COUNTROWS(Purchases),
FILTER(ALL(Purchases), Purchases[Product] = EARLIER(Purchases[Product])&&Purchases[Purchase date] <= EARLIER(Purchases[Purchase date]))
Later = CALCULATE(COUNTROWS(Purchases),
FILTER(ALL(Purchases), Purchases[Product] = EARLIER(Purchases[Product])&&Purchases[Purchase date] >= EARLIER(Purchases[Purchase date]))
Status = IF([Earlier]=1, "Earliest",IF([Later]=1,"Latest",BLANK()))
Hi, Please try with this Calculated Column:
Identifier = VAR FirstTransactionDate = CALCULATE ( FIRSTDATE ( Table1[Transaction Date] ), FILTER ( Table1, Table1[Product ID] = EARLIER ( Table1[Product ID] ) ) ) VAR LastTransactionDate = CALCULATE ( LASTDATE ( Table1[Transaction Date] ), FILTER ( Table1, Table1[Product ID] = EARLIER ( Table1[Product ID] ) ) ) RETURN SWITCH ( TRUE (), Table1[Transaction Date] = FirstTransactionDate, "First", Table1[Transaction Date] = LastTransactionDate, "Last", BLANK () )
Regards
Victor
Lima - Peru
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
95 | |
76 | |
65 | |
51 |
User | Count |
---|---|
146 | |
109 | |
106 | |
88 | |
61 |