Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Measure with columns from different tables

I have 3 tables:

 

a) sales - has multiple columns and two columns I am using for measure; name and quantity

b) cost - has multiple columns of cost for each salesperson

c) exchange rate - retrieving rate from ww.xe.com

 

I created a measure that will calculate the total cost for each salesperson using proper exchange rate and cost.  The calculation I have is shown below.  There is no error on the calculation but I am getting error message when I ran this:

 

The resultset of a query to external data source has exceeded the maximum allowed size of '1000000' rows.

 

My table contains thousand of lines.

 

Any help on the error message and correction on the test_cost is much appreciated.

 

thanks.

 

 

test_cost =
       SUMX (
           sales,
           sales[quantity]
              * SWITCH (
              sales[name],
               "John", Cost[cost_john],
               "Steve", Cost[cost_steve],
               "Mary", Cost[cost_mary],
               "Tiff", Cost[cost_tiff],
               "Kev", Cost[cost_kev],
               1
             )
)

 

cost_john = Sum('Exchange Rates'[Units per USD])*Sum(Cost[john])
cost_steve = Sum('Exchange Rates'[Units per CAD])*Sum(Cost[steve])
cost_mary = Sum('Exchange Rates'[Units per AUD])*Sum(Cost[mary])

 

namequantitytest_cost
Mary253 
Mary127 
Steve111 
Tiff546 
John239 
Mary357 
Kev645 
Mary823 
John186 
John922 
Steve748 

 

6 Replies

  • It reads like you are pulling back to many rows from ww.xe.com.  If you just ask for all exchnage rates for all pairs for all time you will get a pretty big data set.  Perhaps apply some filters to your query to a time range and from and to countries?

    • Anonymous's avatar
      Anonymous
      Not applicable

      Already filtered to CAD, EUR and AUD.

       

      let
          Source = Web.BrowserContents("http://www.xe.com/currencytables/?from=USD"),
          #"Extracted Table From Html" = Html.Table(Source, {{"Column1", "TABLE[id='historicalRateTbl'] > TR > :nth-child(1), TABLE[id='historicalRateTbl'] > * > TR > :nth-child(1)"}, {"Column2", "TABLE[id='historicalRateTbl'] > TR > :nth-child(2), TABLE[id='historicalRateTbl'] > * > TR > :nth-child(2)"}, {"Column3", "TABLE[id='historicalRateTbl'] > TR > :nth-child(3), TABLE[id='historicalRateTbl'] > * > TR > :nth-child(3)"}, {"Column4", "TABLE[id='historicalRateTbl'] > TR > :nth-child(4), TABLE[id='historicalRateTbl'] > * > TR > :nth-child(4)"}}, [RowSelector="TABLE[id='historicalRateTbl'] > TR, TABLE[id='historicalRateTbl'] > * > TR"]),
          #"Promoted Headers" = Table.PromoteHeaders(#"Extracted Table From Html", [PromoteAllScalars=true]),
          #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Currency code#(lf)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)▲▼", type text}, {"Currency name#(lf)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)▲▼", type text}, {"Units per USD", type number}, {"USD per Unit", type number}}),
          #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([#"Currency code#(lf)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)▲▼"] = "AUD" or [#"Currency code#(lf)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)▲▼"] = "CAD" or [#"Currency code#(lf)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)▲▼"] = "EUR"))
      in
          #"Filtered Rows"

      • Anonymous's avatar
        Anonymous
        Not applicable

        I tried to simply the calculation to see if the error message has something to do with multiple rows to:

         

        test_cost = 
               SUMX (
                   sales,
                   sales[quantity]
                      * SWITCH (
                      sales[name],
                       "John", 1.34*Cost[john],
                       1
                     )
        )

         

        Still have the same exceeding error message. So problem is in the statement.

         

        Any ideas?