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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
pbianalyst75354
New Member

Running Total With Logic

Hey everyone,

 

I have included the link to my Dropbox containing two files: Test.xlsx and Questions.pbix. Link is here. The result I am going for is mirroring the Excel formula found in column L (Calc'd Count column) of the Excel file "Test.xlsx" in a calculated column. The result should produce this:

pbianalyst75354_0-1728134844596.png

Currently, I am having trouble getting the DAX code to produce the number of locationsPerInterval (2) for each month and computing the remaining amount when the locations have been met. A more indepth explanation is below.
Example:

If my locations = 13 (total locations),
Delay is 24 (Starting Date),
an interval of 1 (once a month),

and location/interval of 2 (locations available during each interval)

 

..then I should start seeing 2 locations become available 24 months from the first date of my dataset (09/30/2024) and each proceeding date (10/31/2024, 11/30/2024, and so on) should result to 2 until the number of locations (13) has been met. So in this example, I should see a number 2 for months 08/31/2026 though 01/31/2027 and a 1 in 02/28/2028. The 1 is produced for 02/28/2028 because the sum of the prior months equal 12 (2, 2, 2, 2, 2, 2) and there is one remaining location for Feb. And since my total locations of 13 has been met the remaining months after 02/28/2028 should result to 0. 

 

I hope this is clear. Thanks so much in advance if you look at this!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @pbianalyst75354 ,

 

You can create a column.

Column = var _delaystart=RELATED(InputVariables[Dev Delay])
var _inter=RELATED(InputVariables[Loc/Interval])
var _loc=RELATED(InputVariables[Locations])
var _divide=ROUNDDOWN(DIVIDE(_loc,_inter),0)
var _minend=_divide+_delaystart-1
var _maxend=_divide+_delaystart
var _mod=MOD(_loc,_inter)
return IF([Index]<_delaystart,0,IF([Index]>=_delaystart&&[Index]<=_minend,_inter,if([Index]=_maxend,_mod,0)))

vtangjiemsft_0-1728373798555.png

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @pbianalyst75354 ,

 

You can create a column.

Column = var _delaystart=RELATED(InputVariables[Dev Delay])
var _inter=RELATED(InputVariables[Loc/Interval])
var _loc=RELATED(InputVariables[Locations])
var _divide=ROUNDDOWN(DIVIDE(_loc,_inter),0)
var _minend=_divide+_delaystart-1
var _maxend=_divide+_delaystart
var _mod=MOD(_loc,_inter)
return IF([Index]<_delaystart,0,IF([Index]>=_delaystart&&[Index]<=_minend,_inter,if([Index]=_maxend,_mod,0)))

vtangjiemsft_0-1728373798555.png

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

lbendlin
Super User
Super User

Based on our provided sample data. indicate the complete expected outome.

 

The result I am going for is mirroring the Excel formula found in column L (Calc'd Count column) of the Excel file "Test.xlsx" in a calculated column.

Can you describe the formula?  Don't assume that we all have Excel installed.

 

Thanks for replying @lbendlin. The Excel formula is doing what I described in my example explanation: "produce the number of locationsPerInterval (2) for each month and computing the remaining amount when the locations have been met."

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.