Comments for Kasper de Jonge PowerPivot and Power BI Blog » Kasper de Jonge PowerPivot and Power BI Blog All about BI, modelling and DAX for PowerPivot and Power BI Fri, 27 Feb 2015 19:17:00 +0000 hourly 1 Comment on Ask your questions here by Thomas Fri, 27 Feb 2015 19:17:00 +0000 Ben,

Another possible factor is if you are using “DirectQuery” mode in SSAS (many “out of the box” time intelligence functions need to be re-worked to obtain desired functionality). Please follow this link if you would like to assess if you are running in “DirectQuery” mode:

Marco Russo also has a lot to say about changes required in time intelligence functions when running in direct query mode. If DirectQuery applies to your application, there is another url I could leave with you.

Comment on Ask your questions here by Ben Lezin Fri, 27 Feb 2015 17:05:00 +0000 Thanks, will try those. I know Marco Russo is outstanding. I wouldn’t be surprised if there is a different approach for developing DAX in VS versus Excel. Will be interested to see how easy it is to implement Tableau compared to Tabular, since we are still looking at other tools.

Comment on Ask your questions here by Chris Gilbert Fri, 27 Feb 2015 16:52:00 +0000 Hey, sorry it didn’t work for you. It’s so hard (at least for me) to know exactly what problems you’re seeing without a sample model to play with. I’ll still keep trying to point people in the “right” direction. (I wish we had an easy/automatic way to submit such sample data with our questions.)

Well, anyway, I know that Kasper is pretty busy at times. His responses seem to come in spurts, but they’re just about always “spot-on”. It’s tough when you’re really looking for an immediate answer – and probably under a deadline, as well.

You might try posting your question over on

Some pretty sharp guys at both those sites, too.

Most of my work is done in Excel, so I’m pretty much blind to any incompatibilities with tabular models in VS and/or SQL Server.

Comment on Ask your questions here by Ben Lezin Fri, 27 Feb 2015 16:24:00 +0000 Incidentally, is there another forum that you would recommend for these issues? I’ve noticed the questions don’t get any traction from the moderator.

Comment on Ask your questions here by Ben Lezin Fri, 27 Feb 2015 16:22:00 +0000 Didn’t work, but thanks Don’t see many examples using the tabular project in VS, so maybe it’s yet another bug that hasn’t been addressed by Microsoft.

Comment on Ask your questions here by Ben Lezin Fri, 27 Feb 2015 16:20:00 +0000 Nope, but thanks, anyway. Unfortunately, I get the same result, i.e. SUM(RejectMetrics[NewPatientCount]), when I use =TOTALYTD(SUM(RejectMetrics[NewPatientCount]),DimDate[Date])
OR =CALCULATE(SUM(RejectMetrics[NewPatientCount]),DATESYTD(DimDate[Date])).
Could it matter that the fact table may have gaps for some days for certain groupings? Never made a difference when I did it in PowerPivot in Excel.

Comment on Ask your questions here by Thomas Fri, 27 Feb 2015 13:21:00 +0000 Ben, instead of CALCULATE(SUM([NewPatientTotal]), TOTALYTD(DimDate[Date]))”, replace the TOTALYTD with DATESYTD:

= CALCULATE(SUM([NewPatientTotal]), DATESYTD(DimDate[Date])),

Notes: DATESYTD returns a table, while TOTALYTD only returns a scalar (non-table).

If you want to use TOTALYTD, try using two parameters without the CALCULATE like this:

= TOTALYTD( SUM([NewPatientTotal] ), DimDate[Date] ) )

If this works (and I believe it will), I would recommend a great book, just published, on DAX called “DAX Patterns 2015″ by Alberto Ferrari and Marco Russo. The solutions I proposed come straight out of page 27 (see the last formula on page) and page 28 (also, see the last formula on page). Except for Chapters 1 (DAX Fundamentals) and 2 (Time Intelligence Functions) all of the chapters in the book can be found through visiting these two websites:

Comment on Ask your questions here by Chris Gilbert Fri, 27 Feb 2015 12:49:00 +0000 Ben,

I think the problem is that you’re trying to use the TOTALYTD function as a Filter rather than as a Result. The syntax for the CALCULATE() function is:
CALCULATE(, , , …)

Comment on Ask your questions here by Ben Lezin Thu, 26 Feb 2015 22:39:00 +0000 Hello,

I’ve implemented a simple tabular model using SQL Server 2012 SP1 SSDT with a date dimension that has an active relationship with the date key in the fact table and has met the criteria for a date dimension to the best of my knowledge, i.e. no missing dates, etc.

However, when I add a calculated measure in the VS project using any time intelligence function, i.e. =CALCULATE(SUM([NewPatientTotal]),TOTALYTD(DimDate[Date])), the calculated measure only returns the value of the current member, i.e. SUM(NewPatientTotal]) without throwing an error. This is happens for all time intelligence functions!

Are there any best practices that I’ve missed? I’ve scoured the SSAS forums to no avail.



Comment on Ask your questions here by David Wed, 25 Feb 2015 21:04:00 +0000 I have a data set that consists of hospital billing data. I am trying to develop a data model in PowerPivot that will allow for easy calculation of readmissions (for any given patient, any admission that occurs within 30 days of an initial admission is counted as a readmission). One column flags initial admissions (for a particular diagnosis that the hospital is tracking). And a calculated column flags all rows that are possible readmissions:

=CALCULATE(COUNTROWS(DATAtable),ALL(DATAtable),DATAtable[Initial Admission]=TRUE,DATAtable[PatientID]=EARLIER(DATAtable[PatientID]),DATAtable[DischargeDate]=EARLIER(DATAtable[AdmitDate])-30)

This formula works quite well 95% of the time. Occasionally, a single patient is admitted multiple times within the 30-day window. This should only count as one readmission, not multiple readmissions. It seems that I need to sum the calculated column for distinct patients in 30-day windows from the initial admission. Any suggestions?