TabularEditor / TabularEditor3

Bug reports, feature requests, discussion and documentation for Tabular Editor 3 (commercial version).
61 stars 7 forks source link

Empty Measure causes issues, no warning from TE/3 #1194

Closed edhans closed 5 months ago

edhans commented 5 months ago

Description

I somehow created an empty measure using TE/3 with a BIM file connected to a workspace. No PBIX. I am sure I got distracted at some point and never entered any code.

I discovered this about a day after it happened when I was formatting my code using Cristian Angyal's script here - https://github.com/cristiangyal/TE_Macros/blob/main/Format_Selected_or_All_DAX_Measures_plus_Dynamic_Options.csx

The issue was when it got to that measure, it reported this error:

image

Thankfully TE/3 was generating backups for me after every save and was able to use NotePad++ to compare a series of BIM files and spot where the issue happened.

Tabular Editor 3 Version

3.12.1

Screenshots

No response

Steps to Reproduce

  1. Create a new measure
  2. Don't put anything in the Expression window
  3. save the model
  4. Run the script shown above

Expected behavior

My expected behavior would be one of two things:

  1. TE/3 doesn't allow saving the empty measure
  2. TE/3 puts a red box next to the empty measure and it shows up as a problem in the Messages window.

Unless there is a valid reason that empty measures should exist.

Crash Report

No response

Windows Version

Windows 10 and 11

mlonsk commented 5 months ago

Hi @edhans

I can certainly see the issue and agree that a model should not have empty measures. However I am not convinced that this is a issue with Tabular Editor as such for two reasons:

  1. I think it would work much better has a BPA rule as the model itself does not have a problem with empty measures.
  2. The script should have a try/catch method to ensure that it does not crash TE3 when an empty measure is present.

I will take it up internally with the development team and hear their thoughts, and I would also be interested in hearing yours?

edhans commented 5 months ago

Hi @mlonsk ,

I don't object to a BPA, but don't personally find that ideal for two reasons:

  1. The BPA rule has to be installed so users see it
  2. BPA rules, especially early in development, tend to get ignored. for later when cleaning up.

I kind of see this similar to defined variables not used. This is an undefined measure. Similar treatment would be nice - a yellow warning icon for the empty measure.

I will contact Cristian about ensuring the script doesn't crash, because you are correct, this is a valid thing to do, even if it makes little sense.

edhans commented 5 months ago

One other data point. IIRC, you cannot create an empty measure in power bi desktop. It will remove it if you navigate away and the expression is empty.

Not suggesting Power BI desktop flow be followed. Just that for many devs there is no concept that an empty measure can exist. I didn't know it was possible until last week, and it was unintentional.

otykier commented 5 months ago

Hi @edhans Just adding my 2 cents here:

Design philosophy of Tabular Editor is to let users do what they want with the TOM, to not assign values/properties to anything other than their default values without the user explicitly taking some action, and to not be "clever" on the users behalf. This is fundamentally different than what PBI Desktop is doing, in many different ways.

The Messages view is used to indicate Errors and Warnings. If any errors are present, it is almost guaranteed that the developer will face an issue upon deploying the model, or users may encounter errors when querying the model. Warnings do not necessarily cause issues, but they indicate that something unintentional or ambiguous might be going on; such as when unused variables are present in DAX (did the developer forget to update the RESULT statement?), or when a column reference is unqualified (did the developer mean to reference a measure while inside a row context containing a column with the same name?)

Best Practice Rules are intended to cover everything else, and while we don't currently ship a set of default BPA rules, we strongly recommend using the official ones provided by Microsoft.

Empty measures falls somewhere between a Warning and a BPA rule. They are not quite warnings, in that they can't really cause ambiguities, and there might be a legitimate reason to have a blank measure - it's exactly the same as having a measure with the expression: BLANK(). If a C# script doesn't support a blank measure, then that's an issue with the script, not the measure :)

The fact that PBI Desktop doesn't let users add blank measures is not much of a concern for us: Our main focus is the TOM, without any of the weird constraints imposed by Desktop. You can find many similar examples of things that should then also be considered warnings, because Desktop doesn't let you do that, or does it in another way, but where our assumption generally is that the developer knows what they're doing, and they are setting up the TOM in a specific way, because that's what they want to do.

That being said, we've talked internally about creating something like a "Simple Mode" for Tabular Editor, which would be the default for new installations. In this mode, Tabular Editor hides all of the more advanced properties from the TOM, and applies more sensible defaults to newly created objects (hands up if you've ever forgotten to set the "Kind" property of a new Shared Expression created in Tabular Editor). This could also let us hide stuff like partitions, data sources, etc. to provide an experience that is more aligned with Desktop, to help new users coming from Desktop adapt to Tabular Editor. In "Simple Mode", we could also easily imagine a richer set of warning messages to guide the user a bit more than what we do now. Whenever the user feels comfortable enough with TOM, they could then switch over to "Advanced Mode", to get the full Tabular Editor experience that we have today. No specific plans just yet, but it's something that's come up a few times over the years.

mlonsk commented 5 months ago

Just to round of the discussion: Microsoft's official BPA rules have this issue covered. E.i. to highlight any expression objects that do not contain an expression.

image

I will close the issue, and will transfer it to our discussion forum to keep all the good information herein at hand.