Forum Discussion

s_kula's avatar
s_kula
Helper I
3 years ago

DAX finding dates

Hello, I need to calculate 2 values ​​using DAX function.
1. Calculate the penultimate date for product id
2. Calculate the quantity for a given date and product id.

an example table with data is attached.

I will be grateful for your help.


id prod         date                   qty

8217.04.20234
80117.04.20235
63217.04.202311
63217.04.202311
5583-217.04.20233
5583-117.04.20233
553617.04.202330
553517.04.20239
553317.04.20239
553117.04.20239
5528-117.04.202320
5527-417.04.20231
5526-416.04.20236
5526-316.04.20236
5526-116.04.20236
5525-316.04.202320
5525-116.04.202320
5523-216.04.202326
552216.04.20234
552116.04.20234
551716.04.20234
551616.04.20238
551516.04.20235
5510-516.04.20234
548616.04.202312
548516.04.202312
548115.04.202312
542315.04.20232
542115.04.20231
541515.04.202310
5309-115.04.20231
528015.04.202310
526115.04.20232
525-215.04.20233
525-115.04.20235
52415.04.202396
5226-115.04.20233
5220-215.04.20236
52215.04.202396
5219-115.04.202310
5217-115.04.20235
5215-214.04.20231
518-214.04.202330
518-114.04.202350
5043-514.04.20231
5043-414.04.20231
5043-314.04.20234
5043-114.04.20231
5041-314.04.20231
5041-114.04.20236
5040-314.04.20232
5038-414.04.20231
4991-114.04.20231
49214.04.20232
48514.04.20238
481414.04.202384
47814.04.202330
47214.04.20232
47114.04.202310
46813.04.202310
46713.04.202330
46513.04.202310
464713.04.202324
464513.04.202348
461413.04.202310
457513.04.20232
445013.04.20235
424513.04.202312
422413.04.202310
4207-213.04.20231
413213.04.202310
411913.04.20235
389513.04.20238
386813.04.20234
386313.04.20236

3 Replies

  • your sample data only contains one date per product id, so we cannot compute the penultimate date.

  • Hello, actually the data was wrong. I am pasting the corrected ones now.

    In this list, the maximum date is 24/04/2023.
    However, I want to be able to calculate the next e.g.
    22/04/2023 (max-1) and another 17/04/2023 (max-2), i.e. subsequent dates in a decreasing sequence. The function must include a filter for a specific product id.

    At the same time, the result of this function is supposed to be a filter to find other values ​​from a table row.
    e.g.
    date 22/04.2023 for product id 25, is to be a filter to the sales quantity for a given date and product id.

     

    • lbendlin's avatar
      lbendlin
      Super User

      The data is still not good. There is no overlap.