Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new community scripts #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MattAlington
Copy link

No description provided.

@otykier
Copy link
Collaborator

otykier commented Oct 21, 2020

Thanks for your contribution Matt.

Unfortunately, I can't approve the "Replace text strings that occur in many measures" script, since it is too specific. What if my model doesn't have a [Total Sales] measure? What if the original measure was formatted so there would be spaces or line breaks between CALCULATE and SUM? What about the many other possible table/column names that could also occur?

I recommend changing this to some kind of pattern matching. Preferably, use the Measure.Tokenize() function which would return a list of tokens for the DAX expression, making it easier to find a pattern containing the following tokens (in order), ignoring any whitespace, line breaks or comments:

  1. DaxToken.CALCULATE
  2. DaxToken.OPEN_PARENS
  3. DaxToken.SUM
  4. DaxToken.OPEN_PARENS
  5. DaxToken.COLUMN_OR_MEASURE
  6. DaxToken.CLOSE_PARENS

You can use the same pattern matching technique to build an index of all existing measures, to check whether a suitable measure could be replaced, or if a new measure has to be created.

@MikeCarlo
Copy link

I copied this repo and added your file to the following Repo: https://github.com/PowerBI-tips/TabularEditor-Scripts/blob/main/Basic/Create%20Build%20direct%20or%20indirect%20dependency%20tree%20of%20selected%20or%20all%20measures.csx

You are welcome to continue to contribute to this repo as I am actively maintaining the Tabular Editor scripts there: https://github.com/PowerBI-tips/TabularEditor-Scripts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants