DAX Fridays

Поделиться
HTML-код
  • Опубликовано: 7 ноя 2024

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

  • @Bharath_PBI
    @Bharath_PBI 4 года назад +1

    Hi Ruth, another Friday 🙂
    There are Excel functions in power bi DAX functions (kept for Power Pivot engine compatibility), which shouldn't be prioritised over native DAX functions. (DAX functions are much more optimised in it's internally logic when compared to same excel function)
    Another reason I could think of is that because DAX runs on Analysis services, there will be a guid column added in memory when there's no primary key in the table, and count rows is probably programmed to read the unique column count , which is the cardinality of the table.. I read it somewhere, but not able to recall exactly about this..
    Anyways, that's the work for weekend.. 🙂👍 Have a great weekend. Thanks

  • @wkt5916
    @wkt5916 4 года назад

    Also interested in whether indexing the tables will improve the dax efficiency, like SQL?

  • @IssueBoyStefan
    @IssueBoyStefan 4 года назад +1

    Actually, blank cells are treated as an empty string cell, and real blanks - cells with no data in them, are marked with null in power query. You can try to load some data into an excel worksheet and see that those empty strings contain ' in it and they are also treated as text. :)
    It's quite confusing though. The same is when you try to get an empty cell in Excel from let's say IF statement. IF (condition, something,"") will return an empty string (empty text field) and not blank if it's false.
    Hope that makes sense.

  • @qaz56q
    @qaz56q 4 года назад +1

    SSAS Tabular Model (including PowerBI version), creates a hidden column for each table (not available to the user) in
    format like:
    Product Category-RowNumber-2662979B-1795-4F74-8F37-6A1BA8059B61 (it can be seen to connect e.g. in daxStudio to the model and querying DMV.
    And probably counting is done on it. Which probably affects the speed.
    In addition counting blank, this may by faster than COUNTBLANK ()
    CALCULATE (
    COUNTROWS ( 'Table' ),
    KEEPFILTERS ( 'Table'[CloumnWithBlank] = "" )
    )

  • @oliveroshea5765
    @oliveroshea5765 4 года назад

    Hi Ruth!
    How are things going?
    Great video as always!
    I think that when it says COUNTROWS "doesn't consider BLANKs contained in any column of the table" means that it treats nulls, "" and actual values like 5, 6, "apple", "orange", "BIKE", "CAR", true, false all in the same way.
    I quickly created a table : #table(type table[#"Column1"=text], {{null}, {null}, {null}, {null}})
    and then imported it.
    measure countrows = COUNTROWS(Query1) returns 4
    measure count = COUNT(Query1[Column1]) returns (blank)!!
    Seems to match what we saw.
    What do you think? I must check the slack channel!
    Cheers
    Ollie

    • @brianc313313
      @brianc313313 3 года назад

      You are correct. Saying it doesn't consider blanks is not the same as saying it doesn't count blanks. It would be nice if it were documented more clearly, but it's saying it counts the row whether it is blank or not.

  • @bandoggebreeders
    @bandoggebreeders 4 года назад

    COUNTROWS maybe employs some form of (internal) index perhaps?
    Whereas using COUNT on say Order Date, or a non-integer type field would be less efficient? As already hinted at by Aleksander Strömmer, you'd likely have to be working with a sizable data set to see much difference one would think?

    • @CurbalEN
      @CurbalEN  4 года назад +1

      I have no idea of why, wish they would have said in the article...

  • @aleksanderstrommer7677
    @aleksanderstrommer7677 4 года назад +1

    How much faster with diff sizes of data?

    • @CurbalEN
      @CurbalEN  4 года назад +2

      Speed depends on a lot of factors, give it a go yourself with your data and let us know :)

  • @kahhengyeong7947
    @kahhengyeong7947 4 года назад

    I work with large sales tables so most likely COUNTROWS is a 'safer' way because there may be some rows that are left blank.
    Example is that I have to count the number of rejects/warranty returns and definitely not all sales will have that so COUNT might be dangerous that it counts every row. Maybe that makes sense I think?

    • @CurbalEN
      @CurbalEN  4 года назад

      But with the name countrows I would expect to count all rows?
      Maybe they should create a countallrows?
      It is confusing what all those count functions count or skip...
      I might do a new video going deeper in the subject.
      Thanks for your thoughts and happy friday!

    • @kahhengyeong7947
      @kahhengyeong7947 4 года назад

      Hmmm, I' guess I have tuned to the logic to think COUNTROWS is to "count rows with actual data" while COUNT will count everything :) Happy Friday to you too!

    • @CurbalEN
      @CurbalEN  4 года назад

      Need to do that too:)

  • @andrejaar2136
    @andrejaar2136 4 года назад +3

    countrows should perform better because it counts the "from/to" tables that vertipak creates..all data that is agregate, generates a small version(compact) that contains the " name: Q1, from: 1, to: 100000 ; name: Q2, from: 100001 , to: 200000 ; etc... "
    this is what i think, not 100% acc

  • @Victor-ol1lo
    @Victor-ol1lo 4 года назад

    Hi Ruth ! We always COUNT or COUNTROWS on you ... :-) Very very confusing..... Have a nicw weekend !

    • @CurbalEN
      @CurbalEN  4 года назад

      Happy Friday!! 🥳🥳

  • @dianyuanxiaopa
    @dianyuanxiaopa Год назад

    Summary: 1. Empty is not null; 2. COUNT and COUNTA ignore null, but COUNTROW include null.

  • @thomasivarsson2468
    @thomasivarsson2468 4 года назад

    "Kunskap är förvirring men på en högre nivå än tidigare" I think that the problem is DAX does not recognize NULL in the database context as missing value. Instead you get empty strings which is not the same.

    • @thomasivarsson2468
      @thomasivarsson2468 4 года назад

      Glömde en länK www.sqlbi.com/articles/blank-handling-in-dax/

  • @achuthreddykavalakuntla7920
    @achuthreddykavalakuntla7920 4 года назад

    Hi curbal, i had a question which visual is used to display 4 continuous variables ad 2 categories of data, can you help me with this

    • @Bharath_PBI
      @Bharath_PBI 4 года назад +1

      Try scatter chart, with play axis (time) for continuous variables.

  • @alexkim7270
    @alexkim7270 4 года назад

    My assumption as to why COUNTROWS return 7 instead of 5, it is an "additive" model. Logically, you would wanna use an OR operator to count through all rows that are not NULL (I think the documentation meant this instead of BLANK). Instead of "multiplicative" model which uses the AND operator, which is to count the row only if all rows in all columns are not null. To me, this is a risky and faulty data modeling assumption, that I believe COUNTROWS aim to avoid.
    In all 3 columns in the 'Counting' you have at least one value per row. Here's where COUNTROWS would return 7, again since it counts through all rows in the table that doesn't contain NULL.
    As to why it is being more performant, I would say it goes back to the "additive" model assumption where each row in the table has a logic that checks them in the entire table. Otherwise, the engine has to work "harder" to get into the columns.
    We gotta understand that DAX work from the following pecking order: Table > Column > Row (which explains why context transitions usually work the hardest).
    I guess the logic is to answer which is easier to purchase in a store:
    A. 5 packs of flour weighing 1kg each
    B. Weighing 5kg off the big sack of flour
    I know it isn't a great example, but I guess this is where the article is going. Once again, thanks for sharing Ruth. I've never used these formulae but will certainly bear in mind when I need to in future.

    • @CurbalEN
      @CurbalEN  4 года назад

      I am.afraid it is still confusing....maybe when I am older I will get it ;)
      Thanks forntaking the time to explain!

    • @alexkim7270
      @alexkim7270 4 года назад

      @@CurbalEN haha apologies for that confusion. Maybe you can just load one extra row in the table where all 3 columns will be null. I think COUNTROWS would still return 7. If it returns 8 I can eat my own cat food. Hahahaha.

    • @CurbalEN
      @CurbalEN  4 года назад

      🤣🤣

    • @alexkim7270
      @alexkim7270 4 года назад

      I've tried. You can't even load a fully null row at the end of the table. But the interesting stuff I found out is, if you add a null row in between, it will be counted too! 😅😝
      So yeah, suffice to say, it's very confusing to explain.

    • @CurbalEN
      @CurbalEN  4 года назад

      🙈🙈🙈
      Amazing...