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

Update semantic-layer-6-advanced-metrics.md #4789

Merged
merged 4 commits into from
Jan 25, 2024

Conversation

Thelegendlink
Copy link
Contributor

@Thelegendlink Thelegendlink commented Jan 24, 2024

What are you changing in this pull request and why?

Fix indent and incorrect filter and measure in Ratio metrics which are causing errors in implementing the code:

 - name: food_revenue
    description: The revenue from food in each order.
    label: Food Revenue
    type: simple
    type_params:
      measure: revenue
      filter: |
        {{ Dimension('order__is_food_order') }} = true

to

 - name: food_revenue
   description: The revenue from food in each order.
   label: Food Revenue
   type: simple
   type_params:
     measure: food_revenue

Checklist

@Thelegendlink Thelegendlink requested a review from a team as a code owner January 24, 2024 11:38
Copy link

welcome bot commented Jan 24, 2024

Hello!👋 Thanks for contributing to the dbt product documentation and opening this pull request! ✨
We use Markdown and some HTML to write the dbt product documentation. When writing content, you can use our style guide and content types to understand our writing standards and how we organize information in the dbt product docs.
We'll review your contribution and respond as soon as we can. 😄

Copy link

vercel bot commented Jan 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-getdbt-com ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 25, 2024 10:13am

@github-actions github-actions bot added the content Improvements or additions to content label Jan 24, 2024
@runleonarun runleonarun added the new contributor Label for first-time contributors label Jan 24, 2024
@github-actions github-actions bot added the size: small This change will take 1 to 2 days to address label Jan 24, 2024
@mirnawong1
Copy link
Contributor

hey @Thelegendlink thanks for opening this pr! I'd like to loop in @Jstein77 to double check this as it looks like the indentation is part of the type_params for the food_revenue metric. because of this i think this is why it's currently the same indentation level as the other keys within type_params (e.g. like measure).

@Thelegendlink
Copy link
Contributor Author

type_params

Thanks for the prompt review @mirnawong1! Yeah that's causing an issue in parsing the config as type_params doesn't support a filter param, whereas measure does.

@Thelegendlink
Copy link
Contributor Author

type_params

Thanks for the prompt review @mirnawong1! Yeah that's causing an issue in parsing the config as type_params doesn't support a filter param, whereas measure does.

Hmm there is another error after fixing the indent.

  1. measure: food_revenue instead of measure: revenue
  2. It looks like the whole filter might need to be taken out as it relies on another model which is orders
    filter: |
      {{ Dimension('order__is_food_order') }} = true      

otherwise it's causing the error below:

Error #1:
  Message:

    The given input does not match any of the available group-by-items for
    Measure('food_revenue'). Common issues are:

      * Incorrect names.
      * No valid join paths exist from the measure to the group-by-item. 
        (fan-out join support is pending).
      * There are multiple matching join paths.
        (disambiguation support is pending).

    Suggestions:
      [
        "Dimension('order_item__is_food_item')",
        "Dimension('order_id__is_large_order')",
        "Dimension('order_item__is_drink_item')",
        "TimeDimension('order_id__ordered_at', 'day')",
        "TimeDimension('order_item__ordered_at', 'day')",
        "Entity('order_item__order_id')",
      ]

  Query Input:

    WhereFilter(
      ["{{ Dimension('order__is_food_order') }} = true",]
    )
    Filter Path:
      [Resolve Query(['food_revenue'])]
        -> [Resolve Metric('food_revenue')]
    Object Builder Input:
      Dimension('order__is_food_order')

  Issue Location:

    [Resolve Query(['food_revenue'])]
      -> [Resolve Metric('food_revenue')]
        -> [Resolve Measure('food_revenue')]

Update measure: revenue to be food_revenue and remove filter
Copy link
Contributor

@Jstein77 Jstein77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating this @Thelegendlink!

@mirnawong1
Copy link
Contributor

thanks again @Thelegendlink ! for the error you're encountering -- can you try the first suggestion: Dimension('order_item__is_food_item') ?

I'll get this merged for you though to make sure no one else runs into this issue!

@mirnawong1 mirnawong1 enabled auto-merge January 25, 2024 10:11
@mirnawong1 mirnawong1 merged commit 0b26ef4 into dbt-labs:current Jan 25, 2024
4 checks passed
@Thelegendlink
Copy link
Contributor Author

thanks again @Thelegendlink ! for the error you're encountering -- can you try the first suggestion: Dimension('order_item__is_food_item') ?

I'll get this merged for you though to make sure no one else runs into this issue!

Thanks @mirnawong1, it works with the following code:

    filter: |
       {{ Dimension('order_item__is_food_item') }} = 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Improvements or additions to content January-2024 new contributor Label for first-time contributors size: small This change will take 1 to 2 days to address
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants