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 All,
How to calculate Max and Second largest date measure using Created Date column and calculate Total amount where Invoice date less than equal to last date and greater than equal to second largest Date.
Raw Data:- |
|
|
|
|
Product | Invoice Date | Create Date | Cust Id | amt |
Prod1 | 7/11/2019 | 7/5/2019 | 1001 | 1.2 |
Prod1 | 7/10/2019 | 7/6/2019 | 1001 | 0.4 |
Prod1 | 7/9/2019 | 7/7/2019 | 1001 | 0.3 |
Prod2 | 7/8/2019 | 7/8/2019 | 1001 | 1.5 |
Prod2 | 7/10/2019 | 7/10/2019 | 1001 | 2.5 |
Prod3 | 7/11/2019 | 7/13/2019 | 1001 | 0.4 |
Prod1 | 7/15/2019 | 7/10/2019 | 1002 | 1.2 |
Prod2 | 7/8/2019 | 7/11/2019 | 1002 | 0.4 |
Prod3 | 7/11/2019 | 7/12/2019 | 1002 | 0.3 |
Prod3 | 7/14/2019 | 7/15/2019 | 1002 | 1.5 |
Prod1 | 7/10/2019 | 7/8/2019 | 1003 | 2.5 |
Prod2 | 7/11/2019 | 7/10/2019 | 1003 | 1.2 |
Prod3 | 7/15/2019 | 7/12/2019 | 1003 | 0.4 |
Prod1 | 7/10/2019 | 7/11/2019 | 1004 | 0.3 |
Prod2 | 7/11/2019 | 7/12/2019 | 1004 | 1.5 |
Prod3 | 7/15/2019 | 7/15/2019 | 1004 | 2.5 |
Output:- |
|
|
|
|
Product | Pre Date | Last Date | Cust Id | Amt |
Prod1 | 7/10/2019 | 7/13/2019 | 1001 | 1.2 |
Prod1 | 7/10/2019 | 7/13/2019 | 1001 | 0.4 |
Prod1 | 7/10/2019 | 7/13/2019 | 1001 | 2.5 |
Prod2 | 7/10/2019 | 7/13/2019 | 1001 | 0.4 |
Prod1 | 7/12/2019 | 7/15/2019 | 1002 | 1.2 |
Prod3 | 7/12/2019 | 7/15/2019 | 1002 | 1.5 |
Prod1 | 7/10/2019 | 7/12/2019 | 1003 | 2.5 |
Prod2 | 7/10/2019 | 7/12/2019 | 1003 | 1.2 |
Prod3 | 7/10/2019 | 7/12/2019 | 1003 | 0.4 |
Prod3 | 7/12/2019 | 7/15/2019 | 1004 | 2.5 |
Thanks,
Varsri
Solved! Go to Solution.
Hi @Anonymous
Try these MEASURES
Last_date = CALCULATE ( MAX ( Table1[Create Date] ), ALLEXCEPT ( Table1, Table1[Cust Id] ) )
Second_Last_Date = VAR Mydate = [Last_date] RETURN CALCULATE ( MAX ( Table1[Create Date] ), ALLEXCEPT ( Table1, Table1[Cust Id] ), Table1[Create Date] < MyDate )
Hi @Anonymous
Try these MEASURES
Last_date = CALCULATE ( MAX ( Table1[Create Date] ), ALLEXCEPT ( Table1, Table1[Cust Id] ) )
Second_Last_Date = VAR Mydate = [Last_date] RETURN CALCULATE ( MAX ( Table1[Create Date] ), ALLEXCEPT ( Table1, Table1[Cust Id] ), Table1[Create Date] < MyDate )
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 |
---|---|
115 | |
99 | |
86 | |
70 | |
62 |
User | Count |
---|---|
151 | |
120 | |
103 | |
87 | |
68 |