Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
I have created a DAX measure to sum total sales for the previous calendar year. It needs to respect all active filters. When I run my measure it returns (BLANK). I would appreciate any suggestions on how to resolve this issue.
_LYSales =
VAR CurrentYear = YEAR(MAX('invoicehistory'[invoice date]))
RETURN
CALCULATE(
SUM('invoicehistory'[extended price]),
FILTER(
ALLSELECTED('invoicehistory'),
YEAR('invoicehistory'[invoice date]) = CurrentYear - 1
)
)
Solved! Go to Solution.
@Taxidea_Taxus Try:
_LYSales =
VAR CurrentYear = YEAR(MAX('invoicehistory'[invoice date]))
RETURN
SUMX(
FILTER(
ALLSELECTED('invoicehistory'),
YEAR('invoicehistory'[invoice date]) = CurrentYear - 1
),
[extended price]
)
I found the following code resolved my measure issue:
_LYSales = VAR CurrentYear = YEAR(MAX('invoicehistory'[invoice date])) RETURN CALCULATE( SUM('invoicehistory'[extended price]), REMOVEFILTERS('InvoiceHistory'[Invoice Date]), YEAR('invoicehistory'[invoice date]) = CurrentYear - 1 )
I found the following code resolved my measure issue:
_LYSales = VAR CurrentYear = YEAR(MAX('invoicehistory'[invoice date])) RETURN CALCULATE( SUM('invoicehistory'[extended price]), REMOVEFILTERS('InvoiceHistory'[Invoice Date]), YEAR('invoicehistory'[invoice date]) = CurrentYear - 1 )
In this corrected version, REMOVEFILTERS('InvoiceHistory'[Invoice Date]) will remove any existing filters on the Invoice Date column before the calculation is performed. The filter YEAR('invoicehistory'[invoice date]) = CurrentYear - 1 is then applied to calculate the sum of extended price for the previous year.
hi @Taxidea_Taxus ,
what filter context do you have for the expected measure? or with which columns are you plotting the measure?
Thank you for your prompt response to my post! I have tried your suggestion and am reviewing the results. There are three different filter scenarios. Two return (BLANK) and one returns data. I looked at the data (SQL table) and all three scenarios should return data. I am suspicious of this being a date-related issue in the measure. Any further suggestions would be most appreciated. 🙂
@Taxidea_Taxus Try:
_LYSales =
VAR CurrentYear = YEAR(MAX('invoicehistory'[invoice date]))
RETURN
SUMX(
FILTER(
ALLSELECTED('invoicehistory'),
YEAR('invoicehistory'[invoice date]) = CurrentYear - 1
),
[extended price]
)
Thank you for your suggestion. I believe we're getting closer to the solution. The value for this measure changes with each filter selection. Two filter selections return Blank() with the last filter section returning a value. I am wondering if there is a way to return a currency value vs. Blank().
Hello @Greg_Deckler , thank you for the resources you directed my to earlier. I have created a .vpax file of this report. You can view it by clicking here. All measures in this report work as intended with one exception...the _LY Sales. It returns the correct answer but does not respect existing filters as the other measures do. No matter what filter options are used, this filter's output remails the same.
User | Count |
---|---|
52 | |
51 | |
20 | |
17 | |
16 |
User | Count |
---|---|
113 | |
46 | |
44 | |
28 | |
22 |