Context Transition - The Whiteboard #03

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ก.ย. 2024
  • A context transition in DAX transforms a row context into an equivalent filter context: a picture is worth a thousand words!
    Learn abstract DAX concepts in a more interactive way with "The Whiteboard" series. Read more: www.sqlbi.com/...
    #thewhiteboard

ความคิดเห็น • 43

  • @mwaltercpa
    @mwaltercpa 2 ปีที่แล้ว +7

    Visually seeing each row move into the filter context to evaluate (under filter context) really helps solidify the role of row context within a filter context evaluation. Thanks Marco!

  • @richardmartin7904
    @richardmartin7904 2 ปีที่แล้ว +3

    Please keep doing these type of videos. Very useful for people like me.

  • @sarthaks
    @sarthaks 2 ปีที่แล้ว +1

    The most important and complex concept in DAX.. This is really helpful

  • @ozzhernandez8166
    @ozzhernandez8166 2 ปีที่แล้ว +1

    Fantastic serie!!

  • @bradj229
    @bradj229 8 หลายเดือนก่อน

    Thanks for explaining with visuals. It helped me understand a lot easier :)

  • @rahullamba9318
    @rahullamba9318 ปีที่แล้ว +1

    So well explained! Thank you!

  • @Milhouse77BS
    @Milhouse77BS 2 ปีที่แล้ว +2

    7:38 Good point on internal optimization on iteration. Didn't know that.

  • @shafa7668
    @shafa7668 11 หลายเดือนก่อน +1

    Really nice video as usual!

  • @TheBaozi
    @TheBaozi 2 ปีที่แล้ว +5

    This is the best explanation of context transition! Thank you so much! I can't wait to see others episodes.😍

  • @lmblancoancos
    @lmblancoancos 2 ปีที่แล้ว +3

    Thank you so much Marco. This video together your book and articles are the best tool to learn about this concept😀

  • @bravucod
    @bravucod 2 ปีที่แล้ว +1

    Great explanation!

  • @Bharath_PBI
    @Bharath_PBI 2 ปีที่แล้ว +1

    Thank you 👍

  • @Nura853
    @Nura853 2 ปีที่แล้ว +1

    Thank you Marco! Exellent explanation!👏

  • @OlsoNounas
    @OlsoNounas ปีที่แล้ว +2

    At 3:02 you said that the customer table is filtered. Technically, isn't this incorrect? It's the sales table which is filtered and the customer table can only iterate over a filtered version of the sales table, or am I missing something?

    • @marcorusso7472
      @marcorusso7472 ปีที่แล้ว +1

      Good catch! I should have said "the Customer table is filtered by the filter context, BUT because we don't have any filter on Customer columns, then it's iterated entirely". I understand why it's confusing, sorry for that!

    • @OlsoNounas
      @OlsoNounas ปีที่แล้ว

      @@marcorusso7472 thanks for clarifying Marco. Keep up the great work. God bless you guys.

  • @Wzxxx
    @Wzxxx ปีที่แล้ว +1

    Why Distinct and not Values?

  • @DawoodChoudry-r3j
    @DawoodChoudry-r3j 16 วันที่ผ่านมา

    sales amount measure you have created is sum(sales(amount)) or just sales(amount)
    Thanks

  • @simon5296
    @simon5296 10 หลายเดือนก่อน

    Thanks Marco for the video. In your example, I understand after context transition, there are 3 filters (year, brand, and max), but remember the sales amount = sumx (sales, price & qty), so the sales amount itself is a sum over many rows. But on top of that, there is a max. Is the max replacing the sum in the sales amount measure? Is the outcome of max a single row's sale amount, or a sum of the sales amount column? thanks a lot!

  • @powerbinareal
    @powerbinareal 2 ปีที่แล้ว +1

    Muito bom!

  • @williamarthur4801
    @williamarthur4801 2 ปีที่แล้ว +1

    Interesting as ever. I hope you do variables, I'm on that chapter and trying to understand where to put them, I've always placed at very start, but had a situation where I had to declare within Calculate and want to understand 'Why?'. Ottimo libro, ottimo sito, ottimi video. Don't ever drop the catch phrase.

    • @SQLBI
      @SQLBI  2 ปีที่แล้ว

      Variables are scheduled: www.sqlbi.com/blog/marco/2022/07/14/the-whiteboard-video-series-on-sqlbi-youtube-channel/

  • @MTawfik86
    @MTawfik86 ปีที่แล้ว +2

    the most confusing video I have ever watched :)

  • @mshparber
    @mshparber 2 ปีที่แล้ว +1

    Thanks! Can you please show an example where you use two columns inside a MAXX, two columns from different tables, lets say Product and Country. Here DISTINCT or VALUES will not work. What is recommended to use?

    • @marcorusso7472
      @marcorusso7472 2 ปีที่แล้ว +1

      You should use an iteration on either SUMMARIZE ( Sales, Product[Name], Customer[Country] ) or KEEPFILTERS ( CROSSJOIN ( DISTINCT ( Product[Name] ), DISTINCT ( Customer[Country] ) ) ). Which one is better... it depends - usually the former, unless Sales is big (100m rows or more) and the dimensions are small. Measuring it is better.

    • @mshparber
      @mshparber 2 ปีที่แล้ว

      @@marcorusso7472 Thanks, Marco!

  • @liang-tsairlin7053
    @liang-tsairlin7053 2 ปีที่แล้ว

    Hello, I am wondering if you can help me using DAX to identify the customers who have the max sales in the first matrix (table) cited instead of just the numbers. By the way, great presentations for all 3 whiteboards. Thank you.

  • @Spirovsk
    @Spirovsk ปีที่แล้ว

    whats the difference between using distinct versus values ?

    • @SQLBI
      @SQLBI  ปีที่แล้ว

      See www.sqlbi.com/articles/blank-row-in-dax/

  • @sandeepbarge4699
    @sandeepbarge4699 ปีที่แล้ว

    How does it understand that it should take max of sales only for those customers that have sales for given brand and product? Because filters on date and product tables are not propagated to customers table. How and when does it filter customers that have sales only for given brand and date? Sorry if I missed something. Please can you clarify?

    • @SQLBI
      @SQLBI  ปีที่แล้ว

      It does not filter that - but those customers have no sales.

  • @holahandstrom
    @holahandstrom 2 ปีที่แล้ว

    I would create the 'Explicit table' that =MAXX() iterates over.
    It takes less brain-compute to understand, than an Implicit (conceptual) explanation.

  • @1yyymmmddd
    @1yyymmmddd 2 ปีที่แล้ว

    Isn't this explanation simpler: The MAXX function only sees Contoso 2019 rows of the expanded table and calculates max amount for the relevant cell in the visual ?

    • @SQLBI
      @SQLBI  2 ปีที่แล้ว +2

      No, for two reasons.
      1) There is no "visual" in DAX, it's Power BI that translates the visual element into DAX syntax parts.
      2) MAXX iterates Customer, which has an expanded table identical to Customer. Only Sales has a larger expanded table (that is involved in the context transition if you iterate Sales and then invoke CALCULATE), but this is not the case for this example.

  • @coollehavre
    @coollehavre 2 ปีที่แล้ว

    it doesnt work in my sample database : my sales amount are : Total Ventes = SUMX( '💲Ventes', '💲Ventes'[Prix Vente]*'💲Ventes'[Qté] ) and my measure to have the maxx : Max Ventes Commerciaux =
    MAXX(
    VALUES('💲Ventes'[Commercial]),
    [Total Ventes])
    but the result is the same than the SUM, not the MAX by month ?

    • @SQLBI
      @SQLBI  2 ปีที่แล้ว

      You should iterate months.

    • @coollehavre
      @coollehavre 2 ปีที่แล้ว

      @@SQLBI i don't understand that you mean ? that give me the same result . i wrote :
      Max Ventes Commerciaux =
      MAXX(
      VALUES('Calendar'[Mois Année]),
      [Total Ventes])

    • @SQLBI
      @SQLBI  2 ปีที่แล้ว

      Try the sample of the article - if your model provides different results, look at the differences in the data model.

    • @coollehavre
      @coollehavre 2 ปีที่แล้ว

      @@SQLBI ok, where can i get the sample ?

    • @SQLBI
      @SQLBI  2 ปีที่แล้ว

      It's the standard Contoso model we use in most of SQLBI articles - for example, you can use this one: www.sqlbi.com/articles/variables-in-dax/

  • @QuLaZz
    @QuLaZz ปีที่แล้ว

    Maybe it would be better to use Dax studio, to show real data for every step of the calculation.
    So we can see the Distinct Country, Sales Amount for Contoso and 2019, and then to see the Max value.

  • @sourabhpatel3834
    @sourabhpatel3834 ปีที่แล้ว +1

    I am calculating Total sales in two ways but it is providing wrong results
    First way :
    Total sales =
    var sale = SUMX(
    order_details,
    order_details[unitPrice] * order_details[quantity])
    var discount = SUMX(
    order_details,
    order_details[discount] * order_details[unitPrice] * order_details[quantity] )
    return sale-discount
    __________________________________________________________________________________________________
    and the second way ( i am using sale variable):
    Total sales =
    var sale = SUMX(
    order_details,
    order_details[unitPrice] * order_details[quantity])
    var discount = SUMX(
    order_details,
    order_details[discount] * sale )
    return sale-discount
    this two must provide same result ?

    • @SQLBI
      @SQLBI  ปีที่แล้ว +1

      No, the second one use the total value of sale evaluated only once.