locked
DAX Studio Group By RRS feed

  • Question

  • Hello, I am trying to write a statement in DAX Studio... my first try with this. All I want to do is produce a table that groups all of my rows of data by the category (keywordstring), and count them. In SQL I would do:

    Select

    count(pyID),

    keywordstring

    Group By keywordstring

    In DAX Studio I have tried everything I can think of for the syntax but keep getting errors.

    Any thoughts?

    Tuesday, December 18, 2018 10:26 PM

All replies

  • I have written many articles about DAX studio that will help you. If you invest 30 mins reading these, I am sure you will work it out. https://exceleratorbi.com.au/getting-started-dax-studio/ https://exceleratorbi.com.au/introduction-dax-query-language/

    Self Service BI Expert using Power Pivot http://exceleratorbi.com.au

    Wednesday, December 19, 2018 7:15 AM
    Answerer
  • There are many different ways of doing this and watching Matt's videos is definitely a good idea.

    Below are 3 different ways you could write a DAX query to get a similar result to your SQL example

    // EXAMPLE 1
    EVALUATE
    ADDCOLUMNS (
        VALUES ( 'Product Category'[Product Category Name] ),
        "Cnt", CALCULATE ( COUNTROWS ( ( 'Internet Sales' ) ) )
    )

    // EXAMPLE 2
    EVALUATE
    SELECTCOLUMNS (
        'Product Category',
        "Category", 'Product Category'[Product Category Name],
        "Cnt", CALCULATE ( COUNTROWS ( ( 'Internet Sales' ) ) )
    )


    // EXAMPLE 3
    DEFINE
        MEASURE 'Internet Sales'[Cnt] =
            COUNTROWS ( 'Internet Sales' )
    EVALUATE
    SELECTCOLUMNS (
        'Product Category',
        "Category", 'Product Category'[Product Category Name],
        "Cnt", [Cnt]
    )


    http://darren.gosbell.com - please mark correct answers

    Thursday, December 20, 2018 7:56 PM