Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
2 years ago

Weekly Target Calculation Dax

Good day, I need help to create a dax measure, I have a monthly sales goal per executive, what I need to the extent is that to that monthly goal depending on the week of the month in which we are that using the day segmenter, I get 20% of the goal in week 1, week 2 35%, Week 3 25% and week 4 20%, they should be added if you go from one week to the next and in turn I need that week goal to be distributed in the number of days I have in the week.
The column in the calendar table that I have created is composed of the following dax

Week of the Month = IF("Week" & 0 + CALENDAR[Start Week] - CALENDAR[Week First Day] = "Week 0", "Week 1", IF("Week" & 0 + CALENDAR[Start Week] - CALENDAR[Week First Day] = "Week 5", "Week 4", "Week" & 0 + CALENDAR[Start Week] - CALENDAR[First Day Week]))
Thank you very much in advance.

9 Replies

  • Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
    If you are unsure how to do that please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
    Please show the expected outcome based on the sample data you provided.

    If you want to get answers faster please refer to https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

  • Good evening, I'm going to detail as best I can the problem I have with calculation:
    I have a table which keeps the monthly sales target capital amount of the executive

    In turn, that monthly goal, depending on the week of the month, takes a percentage of the monthly goal to have a weekly goal, for example:

    Week1 = 20% of objetivo_mensual
    Week2 = 35% of objetivo_mensual

    Week3 = 25% of the objetivo_mensual

    week4 = 20% of the objetivo_mensual

    What I now need is that the amount taken out in each week is redistributed in the number of days you have each week, the drawback I have is that when I use the SLICER of days attached it does not filter me by week, that is, it does not vary the weekly amount of the objective.
    On the other hand, I need that amount that was calculated weekly to be distributed among the number of days you have each week, since that calculation is compared with the daily sales to be informed of the missing or surplus amount that there is in the sales, I only have problems with the sales objectives

  • Good afternoon, I attach tables to specify information:

    Tablo_Objetivos

    IDVENDEDORPERIODCAPITALOPERATIONS
    701/10/2023527074772
    3301/10/2023396398840
    3701/10/2023339470335
    901/10/202312137404160
    501/10/202318302477190
    601/10/20233596126110
    1001/10/2023932938485
    8201/10/2023508496065
    2001/10/2023900708990
    1101/10/20238615403100

    Tabla_Ejecutivos

    IDVENDEDORSELLER
    5EJECUTIVO_1
    6EJECUTIVO_2
    7EJECUTIVO_3
    9EJECUTIVO_4
    10EJECUTIVO_5
    11EJECUTIVO_6
    20EJECUTIVO_7
    33EJECUTIVO_9
    37EJECUTIVO_10
    82EJECUTIVO_11

    Tabla_Ventas

    fechaalta CapitalPedido CodEjecutivo
    09/10/2023 $ 3.180,006
    09/10/2023 $ 21.200,016
    09/10/2023 $ 274.911,825
    07/10/2023 $ 105.839,9982
    07/10/2023 $ 75.599,995
    06/10/2023 $ 5.400,005
    06/10/2023 $ 118.799,999
    06/10/2023 $ 171.570,007
    05/10/2023 $ 97.199,9937
    05/10/2023 $ 75.599,9933
    05/10/2023 $ 41.040,0010
    04/10/2023 $ 21.200,016
    04/10/2023 $ 24.168,0111
    03/10/2023 $ 323.999,9720
    03/10/2023 $ 47.520,0010
    02/10/2023 $ 64.799,9982
    02/10/2023 $ 53.000,015
    02/10/2023 $ 107.999,9933
    • lbendlin's avatar
      lbendlin
      Super User

      Please indicate what you mean by "week". Ideally your data model should have a Calendar table that clearly indicates week numbers, especially if you are attempting to project weeks onto months.

       

       

  • Good evening, the model does have a calendar table, but for the calculation of the week as the company takes it is the one I attached above, I don't know if it is possible to attach a pbix file with a model summarized in only the tables that intervene in the calculations, I was trying with some formulas to be able to calculate the percentage and use it in the table but I can't get it to filter inside the table I don't know If you could help me with that calculation, the measurement I'm using is as follows

    Weekly Goal =
    VAR MonthlyTarget = SUM(tabla_objetivo[MonthlyTarget])
    VAR TargetWeek1 = MonthlyTarget * 0.20
    VAR TargetWeek2 = TargetWeek1 + (MonthlyTarget * 0.35)
    VAR TargetWeek3 = TargetWeek2 + (MonthlyTarget * 0.25)
    VAR TargetWeek4 = TargetWeek3 + (MonthlyTarget * 0.20)
    RETURN
    SWITCH(TRUE(),
    ISINSCOPE(tabla_objetivo[Vendor]),
    SWITCH(TRUE(),
    VALUES('Calendar'[Week]) = 1,TargetWeek1,
    VALUES('Calendar'[Week]) = 2, WeekGoal2,
    VALUES('Calendar'[Week]) = 3, WeekGoal3,
    VALUES('Calendar'[Week]) = 4, WeekGoal4
    ),
    MonthlyGoal
    )

    But moving the slicer from days to days sets the monthly target

    • lbendlin's avatar
      lbendlin
      Super User
      I don't know if it is possible to attach a pbix file 

       

      Please follow the instructions in the link I posted (twice).

  • Sorry, the image is just an example of my table, I attached the necessary data and formulas that I am using to request your collaboration, I don't know what else you need me to attach to you, calendar table cannot be attached to you due to the number of columns it has

    • lbendlin's avatar
      lbendlin
      Super User

      I hope someone else will be able to assist you.