Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

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 5
tamerj1
Super User
Super User

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
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.

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

Anonymous
Not applicable

Can you tell me the logic how can I return a cumulative sum like 'var x' + 'var x' of previous date in dax calculated column?

amitchandak
Super User
Super User

@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]) ) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors