Forum Discussion
Calculating from Imported & Direct query
Hello,
I have a powerapps app that allows for data input. This app is connected to SQL Server and updates data there.
I use direct query to retrieve data from that SQL Server as i want the most recent data at all times.
I have an imported table from our client's database (it is the G/L data).
What im trying to do is summing the G/L data with user's input, to present the total ammount of G/L value and user's input.
It works fine when i use a single measure :
Total Value =
//calculate the value in the G/L
CALCULATE(SUM('Imported G/L Table'[Value]))+
//calculate the value per month from the pivot structured input table
//if date is not selected, retrieve the sum of all months to calculate total
The problem with this measure is that it is PAINFULLY SLOW. A full minute to drill down through a table or bar chart.
which is very very fast, BUT, it wont return the input data this way when clicking refresh on the power bi service refresh or chrome page refresh.
You could modify the dax like pattern below:
Total Value = SUM ( 'Imported G/L Table'[Value] ) + SWITCH ( MONTH ( SELECTEDVALUE ( 'Dates Table'[DateMonth] ) ), 1, SUM ( 'Input Table'[jan] ) )Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- parry2kSuper User
danielmillion Your data tables need to be unpivoted, it is weird that from backend data is showing up as pivoted, it this how data is stored? if you get unpivoted data and month and value on the rows and then it will be super fast and also follow the best practice.
- v-yuta-msftCommunity Support
You could modify the dax like pattern below:
Total Value = SUM ( 'Imported G/L Table'[Value] ) + SWITCH ( MONTH ( SELECTEDVALUE ( 'Dates Table'[DateMonth] ) ), 1, SUM ( 'Input Table'[jan] ) )Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.