Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
1 year ago
Solved

Visual KPIs for dynamic dates

Good morning everyone,
Thank you so much for reading the post, but after trying, I find myself looking for the solution.
I find a data table where there are DAY, MONTH AND YEAR and also Orders:
MONTH DAY YEAR Orders

JANUARY15202325
JANUARY30202352
FEBRUARY152023345
FEBRUARY30202358
MARCH152023245
MARCH30202356
APRIL152023745
APRIL302023587
MAY152023245
MAY3020232
JUNE1520235
JUNE302023525
JULY15202325
JULY3020236
AUGUST1520237
AUGUST302023142
SEPTEMBER1520235
SEPTEMBER30202356
OCTOBER15202396
OCTOBER30202345
NOVEMBER15202383
NOVEMBER302023555
DECEMBER15202377
DECEMBER3020234
JANUARY1520248
JANUARY30202455
FEBRUARY152024555
FEBRUARY302024861
MARCH15202464
MARCH30202459
APRIL152024245
APRIL30202452
MAY1520248
MAY3020247
JUNE15202477
JUNE30202452
JULY15202464
JULY3020245
AUGUST15202489
AUGUST30202435
SEPTEMBER152024235
SEPTEMBER30202441
OCTOBER152024255
OCTOBER30202458
NOVEMBER15202455
NOVEMBER3020246
DECEMBER15202466
DECEMBER30202448

Now I want to use the KPI chart with incremental decreases:

I want to get a measure that is dynamic, whether I select one day returns the current value, the selected one:

Whatever the trend axis is, as it changes, be it year, month or day.

And in the destination precisely the previous value.

That is, if I select a year, that it is the destination of the previous year, if I select a month, that it is the month of last year, and if I select a day that is the same day last year.

This is what I have tried for current value, but it changes everything at once.

Valor_Actual = 
VAR AnioSeleccionado = SELECTEDVALUE('MasterCalendar'[Year])
VAR MesSeleccionado = SELECTEDVALUE('MasterCalendar'[Month Number])  -- Asegúrate de que este campo contenga solo el número del mes (1-12)

RETURN
CALCULATE(
    COUNT('EncargosAnx'[encargos_id]),
    'EncargosAnx'[fecha] >= DATE(AnioSeleccionado, MesSeleccionado, 1) &&
    'EncargosAnx'[fecha] < EDATE(DATE(AnioSeleccionado, MesSeleccionado, 1), 1)  -- Para incluir hasta el último día del mes
)

I appreciate any help

4 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Syndicate_Admin 

       

      Thank you for your sharing.

       

      Best Regards,
      Yulia Xu

    • migueldfr's avatar
      migueldfr
      Helper IV

      thnak you so much Syndicate_Admin 

      Such a great approach and wonderful way to sove this problem

      I really appreaciate it

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi migueldfr 

     

    Did _AAndrade 's method solve your problem? If yes, could you please mark it as solution? This will help more users who are facing the same or similar difficulties. Thank you!

     

    If you still have questions, please feel free to ask me.

     

    Best Regards,
    Yulia Xu