Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

looping logic to create new column

I have a 'Total Target' value and I want to achieve this 'Target Kg' column which is nothing but Total Target on the daily basis

 

So here is the logic how we getting target based on each date:

 

var A = Calculate(Count([calendar days]), Filter([Holiday]= "No"))

var B= Total Target/ A

if([Holiday]= "No") then Return B + (B of previous day)

else Return B of previous day

 

Can I get the code or suggestions for this kind of looping logic 

 

 

 

 

tamerj1 

5 Replies

  • Anonymous ,Based on what I got

    Join this with a date table having all the dates,

     

    Then you can have data for all dates like

    calculate(lastnonblankvalues(Table[Date], Sum(Table[Target Qty])), filter(all('Date'), Date[Date] <= max(Date[Date]) ) )

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous 
    How does your source data look like? Is it one table or multiple? Do you have a date table? Relationships? What are the names of Tables/Columns involved? Is the total target a total sum of a column or a given fixed value or a parameter? 

    • Anonymous's avatar
      Anonymous
      Not applicable

      yes I have multiple tables (calendar, target) and Total Target is a sum of coumn. It's just I want this Total Target to be segregated on the day basis with the above logic I gave.

      But I don't know how can I apply this looping condition with DAX. I just need a pseudo code for this logic.

      • tamerj1's avatar
        tamerj1
        Icon for Community Champion rankCommunity Champion

        Anonymous 
        Please present sample data of both tables along with the expected result.