GithubHelp home page GithubHelp logo

Comments (7)

marcosqlbi avatar marcosqlbi commented on September 25, 2024

Can you provide the code of the underlying measure(s) ?

from daxstudio.

dgosbell avatar dgosbell commented on September 25, 2024

@marcosqlbi I think I can see the issue. The way [Days to Transfer] used in the calculate makes it look like a measure reference, but then there is also a reference to it inside the values function in the filter where it would also have to be a column reference.

So I think we have that new potential issue we identified with the PowerBI where it's possible to have a column in one table that has the same name as a measure in another table. Then the "expand" feature is incorrectly trying to expand both the measure and the column reference leading to an infinite loop where it eventually overflows the string buffer.

So I think we need to check if the character immediately proceeding the [Days to Transfer] string is NOT one of the following:

  • an alphanumeric character
  • a single quote

To ensure that we only expand measure references and not column references.

I have a test PBIX file where I was able to reproduce this issue and code a fix

from daxstudio.

marcosqlbi avatar marcosqlbi commented on September 25, 2024

In reality you might have a column reference without the table name (e.g. in a SUMX or FILTER function), so this could be not enough. However, I see the problem in being too much restrictive here. Probably the best would be:

  1. Check whether the character immediately proceeding the measure is not an alphanumeric character or a single quote
  2. If condition 1) happens, evaluate whether the measure has the same name of a column in the data model.
  3. If condition 2) is true, then show a warning to the user asking whether he wants to go ahead with the replace or not. If the user cancel, don't do anything
  4. If condition 2) is false or condition 1) is false, do the replace

What do you think about this approach?

from daxstudio.

dgosbell avatar dgosbell commented on September 25, 2024

Yes, I think you are right. The current change I've made will expand out local column references incorrectly as if they were measure references. I'll need to see if I can refine it further along the lines you've suggested. But from my testing it appears that the Tabular engine will resolve the "short" form of a name to a column from the current table if one exists, otherwise it will resolve to the measure, so I think we should maybe do the same.

from daxstudio.

marcosqlbi avatar marcosqlbi commented on September 25, 2024

Yes, but the problem is that understanding what is the "current" table is very complex, we should parse the DAX syntax. You can solve the problem easily just in a calculated column, but what if you have:
SUMX ( Categories, SUMX ( RELATEDTABLE ( Products ), [Price] ) )
Then Price could be, in this order:

  • a column in Products
  • a column in Categories
  • a Measure

I think that using measures and columns with the same name should be forbidden (and it is in Power Pivot and SSAS Tabular UI). Thus, if an author wants to go against the best practices, well, we will provide no support for measure expansion... :)

Let me know if I should take a look to the code, too.

from daxstudio.

DaveStabilify avatar DaveStabilify commented on September 25, 2024

Forgive me for not responding sooner - I did not see the first few comments.

The measure [Days to Transfer] is simply AVERAGE( Investigations[Days to Transfer] ). However, Investigations[Days to Transfer] is a calculated column that provides the days between two other date column values in Investigations (1M row fact table).

But this is where it gets messy because the resulting DATEDIFF of the two date columns can produce a negative result. So the DATEDIFF has to be wrapped in a SWITCH statement in order to accommodate both positive and negative scenarios.

This leads me to the next question - should I create an intermediary table that simply contains the calculated columns (there are more than one) from the fact table?

Thanks for your help.

from daxstudio.

marcosqlbi avatar marcosqlbi commented on September 25, 2024

SQLBI site is working - what is the page you are trying to access?
Please write to [email protected] if you need assistance for that, thanks!

from daxstudio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.