Thinking about your DAX Queries like a SQL Query in Power BI

Поделиться
HTML-код
  • Опубликовано: 13 сен 2024
  • Coming to Power BI with SQL experience? Trying to learn DAX? Patrick shows you how to think about your DAX Queries like a SQL Query in Power BI. We hope this helps you to create DAX Queries that are much more accurate and effective!
    📢 Become a member: guyinacu.be/me...
    *******************
    Want to take your Power BI skills to the next level? We have training courses available to help you with your journey.
    🎓 Guy in a Cube courses: guyinacu.be/co...
    *******************
    LET'S CONNECT!
    *******************
    -- / guyinacube
    -- / awsaxton
    -- / patrickdba
    -- / guyinacube
    -- / guyinacube
    -- guyinacube.com
    **Gear**
    🛠 Check out my Tools page - guyinacube.com...
    #PowerBI #DAX #GuyInACube

Комментарии • 96

  • @eziola
    @eziola 8 месяцев назад +35

    Amazing! Do a whole playlist on DAX Queries. I think it is the most effective way to learn DAX / think in DAX! Thank you and keep em coming!

    • @eziola
      @eziola 6 месяцев назад

      I recently ran into an issue where I had to choose between:
      EVALUATE
      SUMMARIZECOLUMNS
      FILTER...
      FILTER...
      versus
      EVALUTE
      SELECTCOLUMNS(
      CALCULATETABLE(table, [filter condition], [filter conditoin],)
      Both approaches returned the same result, but were very different in memory usage. The SELECTCOLUMNS(CALCULATETABLE) seems to be the way to go.

  • @gerryboy458
    @gerryboy458 8 месяцев назад +19

    Brilliant. What would be even better is if we could use an actual SQL query directly thus be able to leverage all that SQL expertise.

  • @PeteBlake-h9v
    @PeteBlake-h9v Месяц назад +1

    Thank you Patrick, explaining how to handle that pesky "Query(1,1) The expression specified in the query is not a valid table expression" message. This was driving me nuts 'cause I didn't understand why it was occurring and wasn't able to find good explanation for it. Made my day. Thanks again.

  • @mwaltercpa
    @mwaltercpa 8 месяцев назад +2

    So many benefits to this. I love that it’s in the app… I can build in the view, then materialize as a new dim table. It’s also a great way to learn DAX, and simplify the work your measures have to do in the report :) Love it.

  • @soy_leche
    @soy_leche 8 месяцев назад +7

    Would be interested to learn more on this in a slower and more detailed format. This seems to be a lot more complex than SQL for the same queries but would be good to know this.

  • @jurakovtun6763
    @jurakovtun6763 29 дней назад

    Wow, unbelievable quality of the video. The design, transitions and of course, the host! Thank you so much for your work! ❤

  • @simonvaughan5654
    @simonvaughan5654 8 месяцев назад +3

    Amazing stuff Patrick, I always learn something new from each of your videos

    • @GuyInACube
      @GuyInACube  8 месяцев назад +1

      Great to hear! Thanks for watching 👊

  • @thomasivarsson1291
    @thomasivarsson1291 8 месяцев назад +2

    Braces {} are important i noticed. Code with light colour on a light background.

  • @user-jw1fs4dq9n
    @user-jw1fs4dq9n 8 месяцев назад +2

    AH HA moment!! I've been having trouble with DAX because I think in SQL...this connects the dots for sure!

  • @jessesmith4051
    @jessesmith4051 8 месяцев назад +2

    The timing of this video was uncanny. Thanks so much for this.

  • @Herr_Vorragender
    @Herr_Vorragender 8 месяцев назад +4

    Upfront; I have never used PowerBI.
    And so I'm sitting here thinking why would I want yet another syntax to "replace" SQL?
    Maybe it's better or faster somehow. Or maybe I can't use SQL in PowerBI. But in the latter case, whouldn't it have been wiser to integrate the classic SQL syntax into PowerBI?
    I bet it has something to do with the other DAX capabilities.

    • @Tom-kp2lv
      @Tom-kp2lv 8 месяцев назад

      Dax is more powerful and versatile? @Pactrick, is that correct?

    • @Herr_Vorragender
      @Herr_Vorragender 8 месяцев назад

      @@Tom-kp2lv what does "more powerful" mean?
      If PowerBI connects to a MSSQL from where it fetches the data, there is absolutely no way it technically be quicker or less resource hungry.
      If more powerful means that it has more functions to use, then Java would be even more powerful than DAX.
      What do you think?

    • @Tom-kp2lv
      @Tom-kp2lv 8 месяцев назад +1

      @@Herr_Vorragender I'll defer to Patrick or others with more expertise. I only know some SQL and some Dax, my reply was just speculation.

    • @GuyInACube
      @GuyInACube  8 месяцев назад +5

      DAX is the calculation expression language within Power BI. More folks understand SQL than understand DAX. But, if you are creating measures or certain things in Power BI, you have to use DAX. The transition can be painful sometimes to understand. This video is about how you can think about DAX if you are coming in with SQL knowledge.
      Of course, transformations should always be done further upstream. Those things should be done in SQL if possible, and assuming that's the data source. You still would have a need to create calculation measures though. Which is where DAX would come in.

    • @GuyInACube
      @GuyInACube  8 месяцев назад +2

      @Tom-kp2lv it depends 😎 SQL has it's place and is further upstream. But once your semantic model is in place, you will need to create DAX measures for use within visuals. We always say to do data transformations are far upstream as possible. And, when it comes to your specific data, you should be testing for performance to see what gets you better results.

  • @georgebob2268
    @georgebob2268 8 месяцев назад +1

    Awesome video. This has sparked my mind to figure out new ways to use the power of DAX!

    • @GuyInACube
      @GuyInACube  8 месяцев назад

      Great to hear! Thanks for watching!

  • @KoundinyaPulipaka
    @KoundinyaPulipaka 8 месяцев назад +1

    Please let me know after getting the results. What should we do, is it only for analysis if we can utilize the results.

  • @RobertLJ11
    @RobertLJ11 8 месяцев назад +1

    Thank you for the video. This video came right on time. I am attempting to make the mental jump from SQL to DAX and this video is a great help. I'm looking forward to any other trips or tricks you post in the future. 👍🎉🎁

    • @GuyInACube
      @GuyInACube  8 месяцев назад +1

      Awesome to hear! We also had to make that jump from SQL to DAX. It took time. When we made the connection to think about it like a SQL query - it changed our perspective.

  • @elrevesyelderecho
    @elrevesyelderecho 8 месяцев назад +2

    3:40 nice! Didn't know it! 😮

  • @jorrellbonner5303
    @jorrellbonner5303 Месяц назад

    This was great vid, Patrick!!!

  • @melodym5993
    @melodym5993 8 месяцев назад

    Thank you!! It's getting close to transact SQL!! AWESOME!!!😊

  • @GaryThomann-CoGC
    @GaryThomann-CoGC Месяц назад

    Thank for dax studio. If you want to display a list of measures then use the following construct
    EVALUATE {
    CONVERT( MAX( 'table'[measure] ), STRING ) & UNICHAR(10) &
    CONVERT( MAX( 'table'[measure] ), STRING )
    }

  • @kostaskolotouros4345
    @kostaskolotouros4345 3 месяца назад

    Awesome video. Planning to use DAX Studio more often, so thank you!

  • @kaushalpatel426
    @kaushalpatel426 8 месяцев назад +2

    this is going to be crazy.

  • @Tom-kp2lv
    @Tom-kp2lv 8 месяцев назад

    Love this (and your enthusiasm about it).
    One thing, it sounds a bit echo-y - like the room is very "live".

  • @lopypop
    @lopypop 8 месяцев назад +4

    Can you do another video using M like a SQL query? (Power Query is the place I'm most likely to think about data in terms of querying vs DAX is where I'm thinking about building measures)

    • @GuyInACube
      @GuyInACube  8 месяцев назад +4

      Will take a look. It's a very different approach.

  • @ElderCruz
    @ElderCruz 3 месяца назад

    It would be awesome if someday in the future you could create DAX notebooks integrated in Power BI Desktop, just like Jupyter Notebooks with Python or similar to RStudio

  • @alexscorer1
    @alexscorer1 8 месяцев назад +56

    i dont understand why we even need dax.. sql would be much more seamless imo

    • @otavioalves813
      @otavioalves813 8 месяцев назад +6

      DAX was created specifically for tabular models. It has a different approach than sql and several advantages over it.

    • @milpatel83
      @milpatel83 8 месяцев назад +13

      DAX is terrible, quite frankly. I'd urge anyone to just concentrate on SQL and use DAX sparingly. This is my new years resolution.

    • @sweydert
      @sweydert 8 месяцев назад +13

      Lol As a business consultant and DAX pro, I've worked with SQL pros everyday for several years. I seldom use manual SQL myself because DAX opens up a universe of dynamic, interactive reporting possibilities that are several orders of magnitude more powerful than anything you could produce manually in SQL. DAX is like splitting the SQL atom, unleashing unfathomable power. I make far more money than my SQL-centric peers because of this. If you're using DAX and not making at least twice what a SQL pro makes, you're not using it correctly.

    • @antoniogonzalez3143
      @antoniogonzalez3143 8 месяцев назад +7

      @@sweydert “splitting the SQL atom”, this really encapsules the power that DAX brings, but most people don’t need that much power, or cannot use it correctly if their data model isn’t correct. DAX shines best with complex calculations

    • @komanguy
      @komanguy 8 месяцев назад

      Since DAX runs in a certain filter context, Sql would have been confusing. Imagine an sql statement in what you don’t need a where statement because the context is already filtered!

  • @aleksvpYT
    @aleksvpYT 8 месяцев назад

    Fantastic video!!! All I ever wanted!

  • @Ni3Bhosale
    @Ni3Bhosale 4 месяца назад

    Q: Brilliant video, I must say very informative. I write VBA macros but want to get expertise in PowerBI DAX Queries.. Is it right to say that i learn SQL queries and then start my hands on on POWERBI? please advise

  • @nagendrakg5062
    @nagendrakg5062 8 месяцев назад +1

    Q: I hope if Microsoft comes up with a tool that converts the sql to Dax then would be game changer

  • @aravindsampath3223
    @aravindsampath3223 8 месяцев назад

    wow this looks amazing, cant wait to try it out

  • @floricapitu
    @floricapitu 8 месяцев назад

    This looks amazing, thank you! ❤

  • @michaelandreini2920
    @michaelandreini2920 8 месяцев назад

    Hi, loved the video so helpful.
    I don't know if you have created one but I run into issues where the dataset becomes so large when pulling into the model, it takes so long to refresh. Do you have any content around optimizing the data retrieval to either get all that data or for a sub-set of that data?
    Thank you!

  • @dbszepesi
    @dbszepesi 8 месяцев назад +3

    I really don't want to talk about how long I have been using Rows() instead of just using the table constructor '{}' that I just learned about in this video.

    • @GuyInACube
      @GuyInACube  8 месяцев назад +1

      We learn something every day! 👊

    • @ikar2k
      @ikar2k 8 месяцев назад

      That's so true for me too, bro. 👍😅

  • @irwinchawla7209
    @irwinchawla7209 8 месяцев назад

    Great feature!! Thanks for sharing.

  • @nataschalaros418
    @nataschalaros418 2 месяца назад

    Is it possible to make DAX code visible (as tooltip eg) for users?

  • @sachinr6042
    @sachinr6042 8 месяцев назад

    Incredible!.. Thanks for sharing

  • @elrevesyelderecho
    @elrevesyelderecho 8 месяцев назад +1

    2:35 nice! 😮😮 Didn't know it

  • @JBartlett_DMU
    @JBartlett_DMU 8 месяцев назад +1

    I still don't understand why we have to write EVALUATE at the beginning of every DAX query. If all queries must begin with EVALUATE, then the interpreter should automatically add it at runtime if necessary.

    • @yosoylucernario
      @yosoylucernario 8 месяцев назад

      Most of the times you'll start an expression with DEFINE, where you'll define measures and table expressions that you'll use in the EVALUATE expr ssion.

    • @JBartlett_DMU
      @JBartlett_DMU 8 месяцев назад +1

      @@yosoylucernario Then if there are no DEFINE statements, it should still assume the EVALUATE statement.

  • @asn85uk
    @asn85uk 5 месяцев назад

    Hello, thank you for the helpful video. I'm encountering a scenario where I require the use of a subquery. Specifically, I need to retrieve all sales from the salestbl where the customers match those in a distinct list obtained from the customer table. However, I'm facing difficulties implementing this query in Power BI due to the presence of date filters in both the inner and outer queries. While SSRS allows the use of date variables for start and end dates, Power BI seems to struggle with the date range in the inner query. Could you provide guidance on how to address this issue using DAX or M-query? Your assistance would be greatly appreciated. Thank you.

  • @Believer_karma
    @Believer_karma 7 месяцев назад +1

    how to use power bi on MacBook Air?

  • @user-cz2yu1li2q
    @user-cz2yu1li2q 6 месяцев назад

    Hi Guy in a cube,
    Can I've amazon rds for psql , redshift and crowd twist connect to my same report
    How many data sources can I connect to my power bi report, do you have a video?

  • @ajay22111
    @ajay22111 8 месяцев назад

    Thank you so much amazing

  • @Brian-vs9sd
    @Brian-vs9sd 3 месяца назад

    I would love a sql to dax converter. I'm new to dax and my head hurts.

  • @l3ol3lca
    @l3ol3lca 8 месяцев назад

    Nice! But Dax Studio now have more futures that you need.

  • @franciscoribeiro2030
    @franciscoribeiro2030 8 месяцев назад +1

    Can you use this as tables you create in the model or is the goal of this pure testing and analysis of data?

    • @yosoylucernario
      @yosoylucernario 8 месяцев назад

      You can use table expressions to add a calculated tables to your model.

  • @NestorAdrianzen
    @NestorAdrianzen 8 месяцев назад +1

    This is bananas! 🍌🍌🍌

  • @Phoenixspin
    @Phoenixspin 8 месяцев назад

    I wish I was cool like Patrick.

  • @UU-ry6gt
    @UU-ry6gt 8 месяцев назад

    awesome! as usual you make us very keen to research more on this topic!

  • @LouisYassa
    @LouisYassa 3 месяца назад

    I wonder why MS chose this nonintuitive DAX syntax vs just plain sql!

  • @toulasantha
    @toulasantha 8 месяцев назад +1

    Bring in a magic command to DAX where we can chose DAX/SQL

  • @JohnnyWinter-p8r
    @JohnnyWinter-p8r 8 месяцев назад

    Yooooo! So I've been writing DAX as a query language since way back in my SSAS days, when you had to write it in a plain text editor (no intellisense :o) in order to use it in SSRS reports. One question though... I've always used a different syntax to this - partly because TREATAS didn't even exist back in the day. Instead, I wrap my SUMMARIZECOLUMNS in a CALCULATETABLE, which then allows you to pass a psuedo-WHERE clause as a list in the 2nd argument. eg:
    EVALUATE
    CALCULATETABLE (
    SUMMARIZECOLUMNS (
    'Calendar'[Month],
    "Total Freight", [M1]
    ),
    'Calendar'[Year] = 2020
    )
    Is there anything wrong with this alternate syntax? I always found it more intuitive to write my filter predicates as a final step, more like SQL... but I'm the only person I know who seems to do this and have never figured out whether or not my method is egregious.

    • @ashleyeatsmuffins
      @ashleyeatsmuffins 7 месяцев назад

      I'm new to DAX and so can't properly answer you question.
      However my initial thoughts are that:
      'Readability' trumps ' 'cleaner' Code'
      Often readability that colleagues will understand can be better than having the same result written in less lines but being less obvious what is going on - explicitly showing the predicate and even it being encapsulated in CALCULATETABLE (rather than the {} constructor brackets I just learned about in this video) makes it easier to understand.
      The only reason I would (sometimes) argue against this would be for performance reasons, and I'm afraid I can't help answer whether your code could be less performant than other methods!

    • @ashleyeatsmuffins
      @ashleyeatsmuffins 7 месяцев назад

      Side note, I double checked the meaning of Egregious before repeating it and found the old definition funny:
      ADJECTIVE
      outstandingly bad; shocking: "egregious abuses of copyright"
      SIMILAR:
      shocking, horrific, horrifying, horrible, terrible, awful
      ARCHAIC
      remarkably good.

  • @samratrsc
    @samratrsc 8 месяцев назад

    This is cool

  • @damn68
    @damn68 8 месяцев назад

    Beautiful

  • @ifyluv7402
    @ifyluv7402 8 месяцев назад

    Interesting

  • @DarwinSwimsWithTheFish
    @DarwinSwimsWithTheFish 8 месяцев назад +1

    #GeauxTigers 🐅

  • @Nalaka-Wanniarachchi
    @Nalaka-Wanniarachchi 8 месяцев назад

    Yo .DAX and SQL Duo.

  • @HSGG_
    @HSGG_ 2 месяца назад

    why record with potato..

  • @brettyc
    @brettyc 8 месяцев назад +2

    DAX > SQL because of context & data model

  • @mauricioalvarez4230
    @mauricioalvarez4230 7 месяцев назад

    No even close to SQL

  • @echezonaazubike8054
    @echezonaazubike8054 8 месяцев назад +1

    This is not SQL 😆

    • @GuyInACube
      @GuyInACube  8 месяцев назад +2

      You are correct. It is DAX. Patrick was talking about how to think about DAX like a SQL query for those coming from SQL.

  • @tonymiller225
    @tonymiller225 11 дней назад

    {TREAT AS} SWEET AZZ

  • @trabek123
    @trabek123 Месяц назад

    SAR MARKET TO FULLY BULLISH HOGAYA HAI AAJ TO LOSS HOGA AAPKA XD

  • @Emiliosguay
    @Emiliosguay 8 месяцев назад

    DAX studio is dead jaja amazing new functionality

    • @user-xc6qc7zz7y
      @user-xc6qc7zz7y 7 месяцев назад +1

      DAX Studio does a whole lot more than just writing queries. My main use is for quick and easy access to DMVs, and also looking at metrics (VPAX). Theses features are essential for large models and the Power BI query editor doesn't cover these areas.