DAX query

Hi,
I am having some challenging regarding a DAX query which do work but is very very slow, anyboy have any suggestion of another approach to speed up the query. I have found the problem is related to the crossjoin, however I need these fields.
My Query is like this:
EVALUATE
 CALCULATETABLE(
  FILTER(
   CROSSJOIN(
    VALUES('Project'[Projectnavn]),
    VALUES('Project'[Projectowner]),
    VALUES('Project'[Responsible]),
    VALUES('Project'[Area leader]),
    VALUES('Project'[Project leader]),
    VALUES('Activity'[Activity]),
    VALUES('Activity'[Start date]),
    VALUES('Activity'[End date]),
    VALUES('Activity'[Duration]),
    VALUES('Activity'[Percent completed]),
    VALUES('Resource'[Name])
   'Fact'[Number of Project] = 1
  'Activity'[Activity] = "Expected start period" || 'Activity'[Activity] = "Expected preparation start"
I appreciate any suggestions
Thanks!

I believe I have found a problem With the model since I do get Resource name on all Project and therefor any possible outcome. However I know that not all Project have assigned Resources and I would have expected those to not appear. So I will have to check
the model.
Cheers

Similar Messages

  • How to handle 3 different fact tables and measures within a DAX query?

    I am writing a DAX query in DAX studio in Excel against a tabular model that has 4 different Fact tables, but they share the same dimensions. (There's some long story I can't get into here, but unfortunately this is the structure) I want to
    include measures from the 4 fact tables, summarize by the dimensions in a single query output that can be used for a pivot table.  So far I have something like this:
     EVALUATE
    FILTER
        SUMMARIZE
            FactTable1,
            DimensionTable1[Value],        DimensionTable2[Value],
            DimensionTable3[Value],
            Dimensiontable4[Value],
            'dimDateTime'[Month PST],
            DimDateTIme[FiscalYear PST],
            "Measure Score",
            FactTable1[Measure 1],
            "Measure Score 2",
            FactTable1[Measure 2],
        ,Company[CompanyName]="Company ABC" 
    What I want to do is summarize the 3 fact tables by the same dimensions, but I am not sure how to do that within a DAX query.  I am getting an error if I try to include another table statement in the original SUMMARIZE function, even though the FACTS
    do share the same dimension.  Is there an easy way to do this?

    You can use ADDCOLUMNS to add the data from other tables, but you need to use within the SUMMARIZE the fact table that determines the cardinality of the output. If you are not sure (e.g. you project cost and revenues from two fact tables by month and there
    could me months with cost and no revenues, but also months with revenues and no costs), then you should use CROSSJOIN and then FILTER.
    You query might be written as (please note CALCULATETABLE instead of FILTER to improve performance):
    EVALUATE
    CALCULATETABLE (
        ADDCOLUMNS (
            SUMMARIZE (
                FactTable1,
                DimensionTable1[Value],
                DimensionTable2[Value],
                DimensionTable3[Value],
                Dimensiontable4[Value],
                'dimDateTime'[Month PST],
                DimDateTIme[FiscalYear PST]
            "Measure Score", FactTable1[Measure 1],
            "Measure Score 2", FactTable1[Measure 2]
        Company[CompanyName] = "Company ABC"
    Marco Russo http://www.sqlbi.com http://www.powerpivotworkshop.com http://sqlblog.com/blogs/marco_russo

  • Parameter for ORDER BY in DAX query not respected

    I have an SSRS table fed by a parameterized DAX query (utilizing the methods in
    thesearticles). I have all of my parameters working just fine except for those feeding my closing ORDER BY statement (I am offloading the sorting
    to the Tabular for several reasons, including a large tested performance gain over sorting in SSRS). I have defined the ORDER BY as follows:
    ORDER BY @Order1, @Order2, @Order3, @Order4
    I cannot get even the first parameter to work. I can pass arbitrary strings with no impact on the report returned, though if I hard code the ORDER BY in the query, the ordering is respected, so I know this is a problem with the parameter.
    Running a Profiler trace on the server when I fire the SSRS report returns the following as the parameter value for @Order1:
    <Parameter>
    <Name>Order1</Name>
    <Value xsi:type="xsd:string">Dimuser[UserID-Name]</Value>
    This is exactly what I want to replace @Order1, and when I hard code that exact string into my query I get the behavior I want.
    I have played with \ escaping the brackets to no avail.
    Any insight is greatly appreciated.

    I have discovered a workable solution to my own problem.
    The parameter is passed and interpreted as a quoted string, rather than as a field name.
    I altered my query to follow this general format:
    ORDER BY
    SWITCH( TRUE()
    , @Order1 = "User", DimUser[UserID-Name]
    , SWITCH( TRUE()
    , @Order2 = "User", DimUser[UserID-Name]
    In this way I am comparing two quoted strings for equality and providing an unquoted field identifier that Tabular recognizes and can order by.

  • Reading the DAX query plan of a trace against a query on a Tabular model

    Hi,
    I'm monitoring a Tabular model queried by an Excel workbook. Inside SQL Profiler I've choosen as events the VertiPaq SE Query End, the Query End and the DAX Query Plan. But this last event isn't more readable.
    How can I read the info collected in the DAX Query Plan in a simple manner?
    Thanks

    It is fairly complex to read the DAX Query Plan. I don't think there are currently tools that make it easier to read. (Watch the DAX Studio project on codeplex as they may include tools for this in the future.) I would recommend you review the Tabular
    Performance Guide which has a good explanation of the DAX Query Plan:
    http://aka.ms/ASTabPerf2012
    http://artisconsulting.com/Blogs/GregGalloway

  • Tabular DAX Query for MINX, MAXX and AVGX

    Hi,
    I need to create three measure to get value of min, max and avg.
    For example, I have 3 columns in my table. I need to take minimum value of Column3 based on column2. If column2 value is 0, then we have to consider entire table data else only we have to consider
    Column1 Column2 Column3
    AAA         1      150
    BBB         1       50
    CCC         0       25
    DDD        1        40
    EEEE        0        70
    I need to take minimum,maximun and avg value of Column3 based on column2. If column2 value is 0, then we have to consider entire table data. IF column2 value is 1, then only we have to consider the row of column2=1.
    I expect the result as like below. Can you please help to find the DAX query for the measure.
    Column1 Column2 Column3  MinValue
    AAA         1      150            40
    BBB         1       50             40
    CCC         0       25             25
    DDD        1        40             40
    EEE         0         70            25
    EEE         0         70

    Hi,
    I have 3 columns in my table. I need to take minimum value of Column3 based on column2. If column2 value is 0, then i have to consider entire table data else only i have take minimum(column3) by considering rows of column2=1.
    Column1 Column2 Column3
    AAA         1      150
    BBB         1       50
    CCC         0       25
    DDD        1        40
    EEEE        0        70
    Try1:
    Min:=IF(Column2>0,MINX(FILTER(table,[column2]>0),[column3]),Min(Column3))
    Try2:
    Min:=MINX(IF(Column2>0,FILTER(table,[column2]>0),table),[column3]))
    Try3:
    Created Measure called Min1.
    Min1:=MINX(FILTER(Table,[Column2]>0),[Column3])
    And then i made this min1 measure to be hidden.
    Created another measure called Min2.
    Min2:=IF(ISBLANK([Min1]),MIN([column3]),[Min1])
    Both DAX query is not working. Can anyone help to have the correct DAX query to create Min measure based on the conditions.

  • DAX query to calculate distinct count respect to a column after a Filter function - SSAS 2012 Tabular

    Hi,
    I'm trying to build the dax query to determine the distinct count for a column returned by the application of a Filter function.
    evaluate(
    row("counter",
    countrows(
    filter(order_summary,
    year(order_summary[change_date]) = 2013) )
    I need to count the distinct values for an id returned by the Filter function.
    Any helps, please? Thanks

    Hi pscorca,
    According to your description, you want to calculate the distinct values for records where change_date is 2013. Right?
    In this scenario, we can use the DISTINCT() function within COUNTROWS(). Please try the expression below:
    =calculate(
    countrows(distinct(order_summary[column])),
    Filter('order_summary', year(order_summary[change_date])=2013)
    Reference:
    Distinct Count Measure in PowerPivot using DAX
    Related Distinct Count
    Best Regards,
    Simon Hou
    TechNet Community Support

  • DAX - Querying: How to reinforce a filter in order to calculate a year to date

    Dear community,
    I am pulling my hair off due to an issue I am having with the creation of a DAX query (supposed to feed an SSRS report).
    The topic is P&L related, I need to compute the revenue based on specific cost elements, that same query must return additional columns that represent YTD, Forecast,... etc ( a couple of typical aggregations).
    First of all here is the query I currently simplified to explain my issue:
    EVALUATE
    CALCULATETABLE(
    SUMMARIZE(
    GENERATE(
    VALUES(AccountingPeriod[RealAccountingPeriod]),
    FactFInancialTransaction
    AccountingPeriod[Code],
    CostElement[Code],
    CostElement[Group],
    "Revenue", [Revenue],
    "GroupRevenue",
    CALCULATE(
    [Revenue],
    all(CostElement[Code])
    FILTER(
    VALUES(CostElement[Code]),
    CostElement[Code] = "RSFOR" ||
    CostElement[Code] = "RSTHI" ||
    CostElement[Code] = "RSOTH"
    FILTER(
    VALUES(CostElement[Group]),
    CostElement[Group] = "RGOVE"
    FILTER(
    ALL(AccountingPeriod),
    AccountingPeriod[Code] = 201402
    FILTER(
    VALUES(OperationalUnit[OperationalUnitNumber]),
    VALUES(OperationalUnit[OperationalUnitNumber]) = "052"
    The Revenue is simply a SUM of an amount column in FactFinancialTransactions.
    What I am unable to do is compute GroupRevenue where I simply would like to sum the revenues for the elements. Does anybody have an idea on the calculate statement that will help me achieve this?
     I tried doing something like:
    CALCULATE(
    [Revenue], all(FactFinancialTransactions),
    all(CostElement[Code]), Values(CostElement[Group]), Values(AccountingPeriod[code]) Values(OperationalUnit[OperationalUnitNumber]) )
    This does not work at all, it looks like the VALUES(OperationalUnit[OperationalUnitNumber]) context is not reinforced, the value I get in return is actually the one summing ALL operational units.
    PS: I have to keep the filter on OperationalUnit as is because it will actually be a pathcontains statement that can pass multiple values
    Thanks so much for any help
    Mils.

    I am not entirely sure about your requirements and your data model.
    However, I would start using ADDCOLUMNS instead of SUMMARIZE to add columns to the group you need.
    EVALUATE
    CALCULATETABLE (
        ADDCOLUMNS (
            SUMMARIZE (
                GENERATE (
                    VALUES ( AccountingPeriod[RealAccountingPeriod] ),
                    FactFInancialTransaction
                AccountingPeriod[Code],
                CostElement[Code],
                CostElement[Group]
            "Revenue", [Revenue],
            "GroupRevenue", CALCULATE ( [Revenue], ALL ( CostElement[Code] ) )
        FILTER (
            VALUES ( CostElement[Code] ),
            CostElement[Code] = "RSFOR"
                || CostElement[Code] = "RSTHI"
                || CostElement[Code] = "RSOTH"
        FILTER (
            VALUES ( CostElement[Group] ),
            CostElement[Group] = "RGOVE"
        FILTER (
            ALL ( AccountingPeriod ),
            AccountingPeriod[Code] = 201402
        FILTER (
            VALUES ( OperationalUnit[OperationalUnitNumber] ),
            VALUES ( OperationalUnit[OperationalUnitNumber] ) = "052"
    Marco Russo (Blog,
    Twitter,
    LinkedIn) - sqlbi.com:
    Articles, Videos,
    Tools, Consultancy,
    Training
    Format with DAX Formatter and design with
    DAX Patterns. Learn
    Power Pivot and SSAS Tabular.

  • Restriction to Left Outer Joins in PS Query

    Hello I am trying to do Left Outer JOin in PS QUERY. I need to do dept tbl, job code tbl and locatable as left outer joins with JOB Table. Looks like in PS QUERY there is a error message saying as below. Can someone has any workaround to achieve this in PS QUERY. I know I can create a View and use that in PS QUERY but BUsiness Users are dependent on IT, so that doesn't work. Also, adding JOB table multiple times works but I am looking for better solution if anyone had come accorss working through PS QUERY Outer JOins.
    Windows Internet Explorer
    Left outer joins must be joined to the last record in the query. (139,290)
    OK
    Thanks,
    SC.

    Hi Mike,
    According to your description, you want to improve the performance for your DAX query in SQL Server Analysis Service Tabular model, right? Here is a white paper describes strategies and specific techniques for getting the best performance from your tabular
    models, including processing and partitioning strategies, DAX query tuning, and server tuning for specific workloads.
    http://msdn.microsoft.com/en-us/library/dn393915.aspx
    Since this is a complex DAX query, from a support perspective this is really beyond what we can do here in the forums. If you cannot determine your answer here or on your own, consider opening a support case with Microsoft. Visit this link to see the various
    support options that are available to better meet your needs:
    http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone
    Regards,
    Charlie Liao
    TechNet Community Support

  • Query accessing SSAS cube is taking more time in power view report

    Hi,
    My SSAS server is having 16 Core's . I have created a power view in sharepoint site, which is accessing ssas cube.
    The report is taking more time to show the result.  I traced the DAX query using SQL Server profiler. When I ran this DAX query in SSAS server directly, then its taking less time but when the same query running from sharepoint server (power view) , it
    is taking more time. Number of records in the fact table is 300M . 
    Also i tracked the %process time in performance monitor, mostly the line is below 20%. I think the CPU is not fully utilized..
    Could you please help me to improve the performance of my report.
    Regards,
    Arun

    Hi Arun,
    According to your description, you create a PowerView report in SharePoint site connect to SSAS cube, the problem is that it take long time to show the result in the report, now you want to improve report performance, right?
    In your scenario, you said that it takes more time to return the result in PowerView report than run the query directly in SSMS. For a report, its run time contain retrieval data time and render report time. So it takes more time to return the result in
    PowerView report than run the query directly in SSMS. And there are 300M records in the fact table, the performance can be caused by large data. Here is a blog which describes tracks down Power View performance problems.
    http://blogs.msdn.com/b/psssql/archive/2013/07/29/tracking-down-power-view-performance-problems.aspx
    Regards,
    Charlie Liao
    TechNet Community Support

  • SSAS Tabular DAX- Need to get MAX value of the MIN (top)hierarchy level row

    EDIT:
    I got closer to resolving the issue using MAX. 
    However, If I remove the department hierarchy and just place on the MAX measure I get the single largest value out of all departments. 
    It would be ideal if the measure could still SUM the "top level" values across everything in the system if the hierarchy is not placed on the rows grouping.
    So it returns the largest value for a given department, but if the department hierarchy isn't present I need it to return a SUM of all the level 1 values for all departments...
    Basically return MAX value from the MIN L1ID's DeptLevel value, but I can't seem to construct that DAX query.  So if DepartmentID hierarchy is on display it gets MAX per row, but if that is removed it dips into MAX GoalValue for each L1ID grouping with
    the MIN DeptLevel.
    /EDIT
    I have a rather odd data table I'm bringing into a SSAS Tabular model.
    Instead of having all data at each child level and then it adding up to a grand total in the parent, it has a grand total predefined at each child level.
    I just need this tool to display the raw data if at all possible instead of trying to aggregate everything. Filter on active level, ignore child levels.
    Is there a way to do that?
    Example:
    SalesGoalsByDepartmentLevel:
    Level1 (top level) = 5,000
    Level2( lower level) = 0
    Level3(lower still) = 500
    Level 4(lowest) = 4,250
    So note that adding up all the child levels is still $250 shy of the top 5,000.
    IT is just an odd business rule, basically each level is expected to meet that goal or exceed it, the top level goal is 5,000 but management doesn't care where that last 250 comes from, they do are that each defined level is met.
    These levels are in a hierarchy so if I view the top level of the hierarchy it adds up to 4250+500+5000=9750 when I just want to see 5,000 at the top level and the details when they drill down.
    I added a filter to just filter to the top level, but then when I drill down of course those lower levels are blank.
    Is there a way to filter on the current displayed level without aggregating all child levels?
    Thanks!

    You might want to take a look at the Parent-Child Hierarchies pattern here:
    http://www.daxpatterns.com/parent-child-hierarchies/
    You might write DAX code to check what is the "current" level (see BrowseDepth measure in the sample file you can download) and depending on its level, se the filter to blank to all the levels below, so you don't aggregate "children".
    Just an idea, I'm not sure if it corresponds to your requirement and I don't have time to make more tests.
    I hope it will be helpful.
    Marco Russo (Blog,
    Twitter,
    LinkedIn) - sqlbi.com:
    Articles, Videos,
    Tools, Consultancy,
    Training
    Format with DAX Formatter and design with
    DAX Patterns. Learn
    Power Pivot and SSAS Tabular.

  • ISEMPTY Syntax in DAX

    My DAX query was taking a long time to run when I added NOT ISBLANK() condition in CALCULATE statement. After researching for workaround, I found an article that suggested replacing ISBLANK() with ISEMPTY() function in the new SP of SQL Server. I did that
    but when I run my below DAX query now, I am getting error message "The ISEMPTY function expects a table expression for argument '1', but a string or numeric expression was used."
    What am I doing wrong? What is the correct ISEMPTY() syntax?
    evaluate
     filter
      addcolumns
       summarize
        'ET'
        'P'[Name]
       "Column1", calculate (distinctcount('ET'[C_ID]), 'ET'[S_FLAG] = 1, NOT ISEMPTY ('ET'[C_ID]))
      'A'[ID]=289  

    The ISEMPTY function requires a table function such as VALUES, DISTINCT or other... but is not the solution to your issue. You should do two things.
    1) Create a calculated column with a flag TRUE/FALSE so that the filter will be a simple one in calculate
    'ET'[VALID_ID] = NOT ISBLANK ( 'ET'[C_ID] )
    2) Use CALCULATETABLE instead of FILTER:
    EVALUATE
    CALCULATETABLE (
        ADDCOLUMNS (
            SUMMARIZE ( 'ET', 'P'[Name] ),
            "Column1", CALCULATE (
                DISTINCTCOUNT ( 'ET'[C_ID] ),
                'ET'[S_FLAG] = 1,
                'ET'[VALID_ID] = TRUE
        'A'[ID] = 289
    Also consider this, if the result is the same (I don't know if moving the filters outside of SUMMARIZE can result in a lower number of rows removing blanks, and you don't want that):
    EVALUATE
    CALCULATETABLE (
        ADDCOLUMNS (
            SUMMARIZE ( 'ET', 'P'[Name] ),
            "Column1", CALCULATE ( DISTINCTCOUNT ( 'ET'[C_ID] ) )
        'A'[ID] = 289,
        'ET'[S_FLAG] = 1,
        'ET'[VALID_ID] = TRUE
    Marco Russo http://www.sqlbi.com http://www.powerpivotworkshop.com http://sqlblog.com/blogs/marco_russo

  • DAX - Aggregating measures by multiple dimensions.

    I have a pretty simple data warehouse (star schema). DimDate, DimProduct, DimCustomer, FactSalesOrders. I have created a Tabular Model with this data and have several measures in FactSalesOrders. Ultimately, I am trying to consume this data in SSRS
    with a DAX query. Therefore, I need to perform a "group by" function in DAX to group by several attributes from each of the Dimensions and aggregate the measures in the FactSalesOrders table. I've tried summarize, and addcolumns, but the performance
    is slow. 10 seconds to pull a simple "group by" DimDate.FiscalYear, DimProduct.SKU, DimCustomer.CustomerName. Analysis Services within Excel is able to slice this data in less than a second. I'm looking for some insight as to how to write the
    DAX query.

    Hi Mstaples123542,
    According to your description, you want to create "group by" function in DAX query. Right?
    In DAX, the only way to achieve "group by" is using summarize, addcolumns. There's no better way the get the same result with better performance. Since you are using SSRS, I suggest you just use the DAX to get the whole dataset without any group
    and order, then you group and order all data in the SSRS.
    If you have any question, please feel free to ask.
    Regards,
    Simon Hou
    TechNet Community Support

  • Slow Query Performance During Process Of SSAS Tabular

    As part of My SSAS Tabular Process Script Task in a SSIS Package, I read all new rows from the database and insert them to Tabular database using Process Add. The process works fine but for the duration of the Process Add, user queries to my Tabular model
    becomes very slow. 
    Is there a way to prevent the impact of Process Add on user queries? Users need near real time queries.
    I am using SQL Server 2012 SP2.
    Thanks

    Hi AL.M,
    According to your description, when you query the tabular during Process Add, the performance is slow. Right?
    In Analysis Services, it's not supported to make a MDX/DAX query ignore the Process Add of the tabular. it will always query the updated tabular. In this scenario, if you really need good query performance, I suggest you create two tabular.
    One is for end users to get data, the other one is used for update(full process). After the Process is done, let the users query the updated tabular.
    If you have any question, please feel free to ask.
    Regards,
    Simon Hou
    TechNet Community Support

  • Transform power pivot model to query

    hi eb
    after building a power pivot model which includes a number of related tables
    i realized i want to analyze results in a simple table not in pivot tables
    there for my model should result to one table of records.
    So i guess i need to start with a single query which will return a single results table.
    Can i transform my original model to free sql to be used as my data source?
    TIA!
    Rea

    In Excel 2013 you can do this:
    click ribbon Data / Existing Connections
    click tab Tables
    select one of the tables of your PowerPivot model (not the Workbook Data Model at the beginning of the list)
    click Open
    In the Import Data dialog box, confirm you want to import a Table and click OK
    Right-click any of the cells of the table and select Table / Edit DAX menu
    In the Edit DAX dialog box change Command Type to DAX, the write the DAX query you want in the Expression text box, then click OK
    Of course, in order to write the DAX query I suggest you using a better editor such as DAX Studio (more info here:
    http://www.sqlbi.com/tools/dax-studio).
    Marco

  • Measure using UseRelationship not working well when sliced with attributes from the same table

    Hi,
    I have Measure created using the 'UseRelationship' Function, which uses a different datekey to link to the DateDim than the one the table is directly related by. The measure works as expected except in one scenario.
    If I browse the measure using an attribute from the same fact table then the attribute is filtered using active relationship whereas the measure is filtered using the inactive relationship as shown below:
    FACT(2 rows)(Active Relationship to Date using DateKey1)
    SNo     DateKey1     DateKey2     Geo        Amt
    1         20100101     20120101    India      100
    2         20100101     20120101    US         200
    AmtMeasure:=CALCULATE(SUM([Amt]),USERELATIONSHIP(FACT[DateKey2],'Date'[DateKey]))
    If I browse the above measure in excel, with Year selected as 2012, I get 100+200=300. Now if I drag the Geo attribute against the measure I get 2 rows with 100 and 200.
    If I do the same in a power view report I don't get any results after dragging the Geo attribute, whereas I get the correct value of 300 without the geo attribute. I checked the DAX query which the power view generates and figured this is being caused because
    there are no rows in the table with DateKey1 having year 2012. I understand why this is happening this way in a DAX query and not in MDX, but shouldn't both behave in the same way and what is a work around.
    Thanks,
    Sachin Thomas

    Sac, is this still an issue?
    Thank you!
    Ed Price, Azure & Power BI Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

Maybe you are looking for

  • Laserjet CP1025nw color, unable to change Print density

    Hi, I need to raise the "Print Density" to 5 (for pcb toner transfer) on my Laserjet CP1025nw color, but when I open the printer properties I do not have that option in the device settings tab, despite what is said on the help page of that model. OS:

  • Macbook HD broken in after a year and a half of use!

    My name is SAULO RICARDO LOPES, I pediatrician, I have 52 years of age and live in Guarapuava: a city of Parana, Brazil. I am a computer fanatic, I use since 1994. I ever have IBM PC but I have my dream was to buy a Macintosh: the symbol of quality,

  • Static IP wirelessly

    I'm having trouble setting up a Static IP address for my Macbook. I can do it fine when I use Ethernet to connect. But when going wirelessly and using Airport to connect, whatever I do to set up the Static IP fails. I just go into System Preferences,

  • Why do I get corrupted JPEGs when saving images in Camera Raw, CS6, Mac 0S Mavericks

    I occasionally get corrupted JPEG files when processing RAW files in Camera Raw. The images will have lines of pixels that ar out of line, and or whole sections will be truncated and show white or black. I'm using PS CS6, Camera Raw 8.6 on a Mac with

  • How populate itemrenderer items with data.

    How populate itemrenderer items with data. Ie after my app starts I generate an array collection that I want to assign as the data provider to each combobox in my item renderer, which im using in a datagrid.