I have the below median measure that I am using in my report, but when I publish to power bi service, I get this error message "Resources Exceeded This visual has exceeded the available resources. Try filtering to decrease the amount of data displayed". Resource Governing: This query uses more memory than the configured limit. The query — or calculations referenced by it — might be too memory-intensive to run. Either reach out to your Analysis Services server administrator to increase the per-query memory limit or optimize the query so it consumes less memory. More details: consumed memory 11753 MB, memory limit 10240 MB."
I have increase the capacity in both AAS and Power BI but still getting same error.
The measure is
CALCULATE ( MEDIANX( FILTER('rep vFact', 'rep vFact'[loanAmount] > 0), ( 'rep vFact'[loanAmount])) )
Please, how do I optimze this measure to be more efficient. Thanks
MEDIANX is an iterator and FILTER is another iterator. Also You are iterating the full table('rep vFact') which is not a good practice. I will recommend 3 measures. Please test them and give me feedback.
1st Measure:
Measure_01 =
MEDIANX (
FILTER ( ALL ( 'rep vFact' ), 'rep vFact'[loanAmount] > 0 ),
'rep vFact'[loanAmount]
)
2nd Measure
Measure_02 =
MEDIANX (
CALCULATETABLE ( 'rep vFact', 'rep vFact'[loanAmount] > 0 ),
'rep vFact'[loanAmount]
)
Related
I have a table in Power BI which contains information on people who are supported by our organisation. We offer a number of different services and user could access one or more of these services in a given time period.
My table looks like this:
From here we can see that the user with serial number 102617 accessed two services in January 2020 (Community Services and Publication).
I need to report on how many people have been supported by multiple services. The output should look something like this:
I am fairly new to DAX and I know that I need a measure because it needs to calculate within the current filter context (filtered by date range).
I have tried the following code and it gets me part of the way there.
Total =
SUMX(
VALUES(Supported[SERIALNUMBER]),
CALCULATE(DISTINCTCOUNT(Supported[Service Type]))
)
If I chart this measure against SERIALNUMBER I get this output:
This makes me think I'm on the right track because it shows that 6 people are being supported by 3 services - as the sample output above confirms. But I want that number 6 to be my measure.
All the rest of my report works but I cannot figure out how to do this last part. Many thanks for any advice offered.
First of all, you need to create a dimension table for the Number of Services.
You can do this using Power Query:
let
Source = Table.FromList({1..List.Count(List.Distinct(Supported[Service Type]))},Splitter.SplitByNothing(),{"Number of Services"}),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Number of Services", Int64.Type}})
in
#"Changed Type"
Or using DAX:
Services = GENERATESERIES ( 1, DISTINCTCOUNT ( Supported[Service Type] ) )
then rename column as required.
Now you can create a couple of measures:
Number of Services Used:
Number of Services Used = DISTINCTCOUNT ( Supported[Service Type] )
People:
People =
COUNTROWS (
FILTER (
SUMMARIZE (
Supported,
Supported[SERIALNUMBER],
"NumServices", [Number of Services Used]
),
[NumServices] >= MIN ( Services[Number of Services] ) &&
[NumServices] <= MAX ( Services[Number of Services] )
)
)
People (Cumulative):
People (Cumulative) =
COUNTROWS (
FILTER (
SUMMARIZE (
Supported,
Supported[SERIALNUMBER],
"NumServices", [Number of Services Used]
),
[NumServices] >= MIN ( Services[Number of Services] )
)
)
This gives the following, for your (tiny) data sample:
I want to group the product name and cost per unit using measure. Can anyone help me with this?.
I have table like this - SUMMARIZE(Data,Data[Product name],Data[Cost Per Unit]) - How to calculate sum from this result.
For example I should get result like Chain - 500 by using measure
Hi create a new calculate table and use ADDCOLUMNS to do the aggregation
ADDCOLUMNS (
SUMMARIZE ( Data, Data[Product name], Data[Cost Per Unit] ),
"Sum of cost per unit", SUM ( Data[Cost Per Unit] )
)
Note:
This is not recommended please use power query group by as much as possible
I hope someone can help me with this. It's probably pretty simple for some of you:-).
I have created a running total in Power BI to show my cash flow and it works well. Now, when I include a measure called "cash injection" as the starting value, the running total only shows the cash injection value throughout the entire time period instead of just today's date.
(Side note: The measure "cash injection" is adjustable using a slicer.)
Below is my running total formula which works, but when I add my measure (cash injection ($)) I run into the issue. FYI: there is no relationship between Append and Cash injection
Thank you!
Total Due ($) running total in Day =
[Cash injection ($)]
+ CALCULATE (
SUM ( 'Append1'[Total Due ($)] ),
FILTER (
ALLSELECTED ( 'Rolling_Calendar'[Date].[Day] ),
ISONORAFTER (
'Rolling_Calendar'[Date].[Day],
MAX ( 'Rolling_Calendar'[Date].[Day] ),
DESC
)
)
)
This is kind of similar to my question here, but different enough i think to justify a new question. Looking at the below table, i want to take the total of Direct Expense across all regions, and subtract that from the Americas Expense number only, then total up the result.
I'd like the last column's total to read 17,661, not 54,888. Here is a link to a sample workbook on OneDrive with the above table: https://1drv.ms/u/s!Al7VQqB8RVlWgY4mUYqouesRPNE0qw?e=IiMPnq Any ideas?
Your measure had two issues:
it was missing the context transition, this can be fixed adding
CALCULATE where a context transition is needed
The [Total Direct Expense total for Region (c)] uses ALLSELECTED,
ad it's called inside an iterator. But we can move the measure
before the iteration using a variable instead. (The number 13,703 is wrong)
The measure then becomes
Final Result (a-c) =
VAR TotalExpense = [Total Direct Expense total for Region (c)]
RETURN
SUMX (
VALUES ( Sheet1[Region] ),
IF (
Sheet1[Region] = "Americas",
CALCULATE (
SUM ( Sheet1[Total Expense (a)] ) - TotalExpense
),
CALCULATE (
SUM ( Sheet1[Total Expense (a)] )
)
)
)
Now the final result is
A rather complex article about ALLSELECTED explaining what is the shadow filter and why calling ALLSELECTED after a context transition in an iteration doesn't work as expcected can be found here https://www.sqlbi.com/articles/the-definitive-guide-to-allselected/
I am facing this issue in understanding how to add a measure Amount LTD which looks back to all the data for projects since its start.
I am able to give total amounts per project between the dates on the data slicer but unable to get Amount which looks back beyond the data filters applied and get the LTD sum value till the to date selected on the date slicer.
Can someone please help.
TIA.
See this Cumulative Total pattern.
Cumulative Quantity :=
CALCULATE (
SUM ( Transactions[Quantity] ),
FILTER (
ALL ( 'Date'[Date] ),
'Date'[Date] <= MAX ( 'Date'[Date] )
)
)