Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

SUMX issues - converting from Import to DirectQuery

Hi - I'm hoping someone can help. I'm switching from an Import report to a DirectQuery and recreating the measures I created for the Import tables. One of the measures I have that worked using Import mode is as follows:

 

ProjectBudget = SUMX('projectorders','projectorders'[units]*'projectorders'[unitsell])

This is multiplying the number of units by the sell price of the unit to show the total project budget. The measure works (ie. no errors on the measure itself) however when displayed in a Matrix, it can't display citing an ODBC error and suggesting using a simpler expression. Trouble is, I'm not knowledgeable enough in Power BI to know what that might look like! It seems SUMX perhaps isnt supported in DirectQuery mode but I'm unsure how to acheive the same as I used for Import mode.

 

 

Any help will be very gratefully received! Thanks.

 

  • Hi Anonymous 

     

    I could not reproduce this. I import your data into a SQL Server database and connect to it in Direct Query mode. When I use this measure in a matrix visual, it works well. 

     

    What data types are your units and unitsell columns in the data source? Do you perform any transformation steps in Power Query Editor? 

     

    Regards,
    Community Support Team _ Jing

6 Replies

  • Anonymous , I think this may be because of line-level calculation which returns more than 1 Million rows.

     

    What are expected lines at row level

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi amitchandak - thanks for offering to help - much appreciated.

       

      Firstly I have a projectorders table which looks something like this - each one associated with a project ID

      Project IDProjectOrdersUnitsUnitSell
      exampleprojectID1exampleprojectorderID12£500
      exampleprojectID1exampleprojectorderID21£500
      exampleprojectID2exampleprojectorderID35£500
      exampleprojectID2exampleprojectorderID42£300

       

      I'm trying to create a Matrix visual that then contains a list of all the projects but roll up the project budget (units * unit sell) from the project orders associated with the individual projects. The bit is red is where I'm struggling! I've tried using SUMX but it fails when added to a matrix visual in DirectQuery mode (works with import mode).

      Project IDProject DescriptionProject ManagerProject budget
      exampleprojectID1egProjectDescription1egPMName1£1500 (sum of related ProjectOrders in above table)
      exampleprojectID2egProjectDescription2egPMName2£3100

       

      I hope that helps explain what I'm trying to acheive!

      • Anonymous's avatar
        Anonymous
        Not applicable

        Sorry - those tables didnt format well once submitted. I'll try again here:

        Table:

         

        Matrix visual content:

         

  • v-jingzhang's avatar
    v-jingzhang
    Community Support

    Hi Anonymous 

     

    I could not reproduce this. I import your data into a SQL Server database and connect to it in Direct Query mode. When I use this measure in a matrix visual, it works well. 

     

    What data types are your units and unitsell columns in the data source? Do you perform any transformation steps in Power Query Editor? 

     

    Regards,
    Community Support Team _ Jing

    • Anonymous's avatar
      Anonymous
      Not applicable

      After creating a new dataset with the data and not applying any 'type' as 'decimal' to the columns I managed to get this working. Thanks for sowing the seed. I just needed to ensure the columns had the right type set. Thanks so much!

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi v-jingzhang , thanks for trying this out. The 'Units' and 'UnitSell' are decimal and currency data types respectively. The source is from a table in Dataverse. The only transformation in power query editor is to filter some rows and rearrange columns.

       

      Many thanks.