Forum Discussion

Glaeran's avatar
Glaeran
Frequent Visitor
7 years ago
Solved

{SSAS] DateDiff not working with calculated columns(?) / Way to calculate MIN X based on two columns

Hey,

Thing occured in SSAS2017, however it might be relevant as well in PowerBI, but hopefully someone will be able to help me with that.

I have data structured like that:

 

 

 

 

 

 

 

What I want to do is calculated DATEDIFF between minimum Value of DateVal1 per DimCol1 and DimCol2 and DateVal3.

In order to do that I created a calculated column MinDateVal1 (I did similar thing fomr MinDateVal2) using:

=CALCULATE(MIN([DateVal1]), ALLEXCEPT('Table1',[DimCol1],[DimCol2]))

So I got a data set like that:

 

 

 

 

 

 

 

Later on I proceed with calculating DateDiff (I will simplify that as originally it also checks whether CalcMinDateVal1 is empty, and if it is, it uses CalcMinDateVal2):

=DATEDIFF([CalcMinDateVal1];[DateVal3];DAY)

 

Results are correctly displaying in SSDT, however after deploying model and checking data quality in Excel, I recieved message:

"cannot query internal supporting structures for column <calculate column> because they depend on a column, relationship, measure  that is not processed. please refresh or recalculate the model. "

Even though I refreshed, recalculated, full pulled the entire model couple of times, error still perssits.

 

My bet is that I can't use DATEDIFF on both calculated column + regular column, due to some context filtering, etc etc. but that's just pure bet, but if someone could confirm that it would be cool

 

My workaround would be to calculate MinDateVal1 and MinDateVal2 as regular columns using PowerQuery, but I don't really have an idea how to write it properly in M and I'd be grateful for help here.

 

3 Replies