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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

'Working on it' hangs when combining multiple calculation into one column

Hi All, 
I have a specific calculation that works OK when seperated to different columns, but hangs when trying to combine it all into one column.

The specifics

I have a table that gets updated weekly that have the following columns: fileDate, id, total.
In order to get a monthly total for each id, first, I'm calclating the fileDate 4 weeks ago (previousDate).
To avoid 'missing' new id's, or old id's with no new activity - if the id in previousDate does not exist, I'm using the second-to-max date in which the id is found (alternateDate).
Finally I use this date to LOOKUPVALUE the old total to subtract from the total for each fileDate.

When this is seperated to two different columns as follows it works with no issues :

First column: determins which date to use for the id

.dateChoice =
VAR previousDate = MAXX(FILTER(ALL('table1'), 'table1'[fileDate] <= ('table1'[fileDate])-28), 'table1'[fileDate])
VAR alternateDate = CALCULATE(MAX('table1'[fileDate]), ALLEXCEPT('table1','table1'[id]),'table1'[isMaxDate] = FALSE())

IF(previousDate <> 0 , previousDate,
IF(aslternateDate <> 0 , aslternateDate, 'table1'[fileDate]))

 Second colum: LOOKUPVALUE for total using the date in the first column and subtract: 

totalDiff = 
VAR previousTotal = LOOKUPVALUE('table1'[total], 'table1'[fileDate], 'table1'[dateChoice], 'table1'[id], 'table1'[id])
'table1'[total] - previousTotal

When I try to combine them into a single colum I get 'Working on it' stuck forever (I tried waiting 45 minuts before giving up)

VAR previousDate = MAXX(FILTER(ALL('table1'), 'table1'[fileDate] <= ('table1'[fileDate])-28), 'table1'[fileDate])
VAR alternateDate = CALCULATE(MAX('table1'[fileDate]), ALLEXCEPT('table1','table1'[id]),'table1'[isMaxDate] = FALSE())
VAR dateChoice = IF(previousDate <> 0 , previousDate,
IF(alternateDate <> 0 , alternateDate, 'table1'[fileDate]))

VAR previousTotal = LOOKUPVALUE('table1'[total],'table1'[fileDate], dateChoice, 'table1'[id], 'table1'[id])

RETURN 'table1'[total] - previousTotal


I guess I have two questions here
1 - What am I missing here? Since my table already has ~80 columns I really prefer to keep this number as low as possible.

2 - Is there a way to 'cancel' when 'Working on it' hangs without killing the task? This was the first time this happened to me and it was quite painful 🙂 

Thank you!

Super User
Super User

Rather than using MAX and LOOKUPVALUE, just use TOPN

Total diff =
var currentTotal = 'table1'[total]
var currentDate = 'table1'[fileDate]
var prevTotal = SELECTCOLUMNS( TOPN(1, FILTER( ALLEXCEPT( 'table1', 'table1'[id]), 
   'table1'[fileDate] <= currentDate - 28 ), 'table1[fileDate], DESC), "@val", 'table1[total])
return currentTotal - prevTotal
Frequent Visitor

Thank you for the reply! I really have a lot to learn in Power BI, most of the time I'm just using the tools I already know that do the job.
When trying the solution you offered I get the error "A circular dependency was detected" on Total diff column, do you have any thoughts on why this is happening?
Thanks again!

its possible that the column itself is being included in the TOPN calculations, try replacing that line with

   FILTER( ALLEXCEPT( 'table1', 'table1'[id]), 
   'table1'[fileDate] <= currentDate - 28 ), 
   "@fileDate", 'table1[fileDate], "@value", 'table1[total])
@fileDate, DESC), "@val", [@value])

Helpful resources

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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


Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.