Forum Discussion

tamirk's avatar
tamirk
Frequent Visitor
11 years ago

Group By for Salesforce Query

Hi,

 

I'm using a salesforce datasource and I wanted to do a group by over an object. This seems like a simple thing and it works fine in other sources, but in salesforce it doesn't. No matter what object I try, or group by option I try, the result is always empty, probably meaning an error some where (but there's no message to that).

 

Does anyone have any experience with such a case?

 

Thanks,

T



11 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    First, are you using the service, Excel or Power BI Desktop when connecting to your Sales Force instance?

    • tamirk's avatar
      tamirk
      Frequent Visitor

      Sorry about that...

      I'm using Power BI Desktop

      • Greg_Deckler's avatar
        Greg_Deckler
        Icon for Community Champion rankCommunity Champion

        As a work-a-round, you can use the matrix visualization to group the data after you have loaded it, or create a new query to create a table just on the column you want to group by, remove duplicates, and then link the talbles together, you can then use that to group things in your visualizations.

  • curth's avatar
    curth
    Icon for Power BI Team rankPower BI Team

    Can you post the text of the query you're trying (or send it privately, if you prefer it to remain private)?

    • tamirk's avatar
      tamirk
      Frequent Visitor

      Sure

       

      let
      Source = Salesforce.Data(),
      Investment__c = Source{[Name="Investment__c"]}[Data],
      #"Filtered Rows" = Table.SelectRows(Investment__c, each ([Status__c] <> "Cancelled")),
      #"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Id", "Name", "Amount__c", "Total_Amount_Received__c", "Commitment__c"}),
      #"Grouped Rows" = Table.Group(#"Removed Other Columns", {"Commitment__c"}, {{"Count", each Table.RowCount(_), type number}})
      in
      #"Grouped Rows"