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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
v-tangjie-msft
Community Support
Community Support

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
v-tangjie-msft
Community Support
Community Support

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.