Hello,
How does one create a measure that adds a Slicer Filtered Measure to a Non-Slicer measure?
Say, that a Slicer Filtered Measure is defined as:
Solved! Go to Solution.
I was able to come to a solution. I don't believe that the solution is the best way to handle the calculation.
Here is what was done: Create a duplicate table to 'Open Orders' , then calculate the static value needed.
The problem is when adding two measures, one being dynamic based on a slicer and the other static.
Created a duplicate table called: 'Open Orders II'
Calculation:
I was able to come to a solution. I don't believe that the solution is the best way to handle the calculation.
Here is what was done: Create a duplicate table to 'Open Orders' , then calculate the static value needed.
The problem is when adding two measures, one being dynamic based on a slicer and the other static.
Created a duplicate table called: 'Open Orders II'
Calculation:
The following DAX measure was developed but it still doesn't total correctly:
TotalSalesAmount3 =
VAR SelectedDate =
SELECTEDVALUE('Date Selection'[Date Selection])
VAR MinDate =
SWITCH (
SelectedDate,
"Current Month", DATE(YEAR(MAX('Open Orders'[ShipDate])), MONTH(MAX('Open Orders'[ShipDate])), 1),
"Current Year", DATE(YEAR(MAX('Open Orders'[ShipDate])), 1, 1),
"Current Week", MIN('Date'[Day]),
"Current Quarter", DATE(YEAR(MAX('Open Orders'[ShipDate])), SWITCH(CEILING(MONTH(MAX('Open Orders'[ShipDate]))/3,1),1,1,2,4,3,7,4,10), 1),
"Last 2 Years", DATE(YEAR(TODAY())-1, MONTH(MAX('Open Orders'[ShipDate])), DAY(MAX('Open Orders'[ShipDate]))),
"Today", TODAY(),
BLANK()
)
VAR MaxDate =
SWITCH (
SelectedDate,
"Current Month", EOMONTH(MinDate,0),
"Current Year", DATE(YEAR(MAX('Open Orders'[ShipDate])), 12, 31),
"Current Week", MAX('Date'[Day]),
"Current Quarter", EOMONTH(DATE(YEAR(MAX('Open Orders'[ShipDate])), SWITCH(CEILING(MONTH(MAX('Open Orders'[ShipDate]))/3,1),1,3,2,6,3,9,4,12), 1), 0),
"Last 2 Years", TODAY(),
"Today", TODAY(),
BLANK()
)
VAR PriorMonthStartDate =
CALCULATE (
DATE(YEAR(MinDate), MONTH(MinDate) - 1, 1),
ALLSELECTED('Date Selection')
)
VAR PriorMonthEndDate =
CALCULATE (
EOMONTH(PriorMonthStartDate, 0),
ALLSELECTED('Date Selection')
)
VAR OpenOrderSales =
CALCULATE (
SUM('Open Orders'[OpenOrderLineAmount]),
FILTER (
ALL('Open Orders'[ShipDate]),
'Open Orders'[ShipDate] >= MinDate && 'Open Orders'[ShipDate] <= MaxDate
)
)
VAR InvoiceSales =
CALCULATE (
SUM('Invoices'[InvoiceLineAmount]),
FILTER (
ALL('Invoices'[InvoiceDate]),
'Invoices'[InvoiceDate] >= MinDate && 'Invoices'[InvoiceDate] <= MaxDate
)
)
VAR PriorMonthAmt =
CALCULATE (
SUM('Open Orders'[OpenOrderLineAmount]),
FILTER (
ALL('Open Orders'[ShipDate]),
'Open Orders'[ShipDate] >= PriorMonthStartDate && 'Open Orders'[ShipDate] <= PriorMonthEndDate
)
)
RETURN
OpenOrderSales + InvoiceSales + PriorMonthAmt
@Blevels ,based on what I got
You should use date table and time intelligence for prior values
example
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s
Hi,
Thanks for taking the time to respond to my post.
Note, I created a new measure based on the suggested measure [last month Sales]. The return value is (Blank). The value returns (Blank) with and without the Slicer Filter.
This is the formula used:
User | Count |
---|---|
77 | |
38 | |
33 | |
15 | |
12 |
User | Count |
---|---|
84 | |
29 | |
26 | |
16 | |
13 |