Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi all,
I would like some help with this one please. I have the below DAX calculation and it is working fine:
TEST Custom Sales =
CALCULATE (
[Sales],
FILTER (
SalesFact,
RELATED('Date'[Financial Year]) = Max( 'Date'[Financial Year] )
)
)
The issue is when I select a value from a report filter, for example Product = "Shoes", the calculation returns (Blank)..
On the other hand when i specify a fixed value in the filter, the product filter works fine:
TEST Custom Sales =
CALCULATE (
[Sales],
FILTER (
SalesFact,
RELATED('Date'[Financial Year]) = 2020
)
)
Tables Date, Product, SalesFact are linked properly so there is no issues with the model.
Can anyone help me resolve this problem?
Thanks for your message.
The idea behind the calculation is to calculate total sales for financial periods. Sadly i cannot use conventional calendar calculations hence have to do it this way.
Any suggestion on how to accomplish this?
This does the same but is following Best Practices and it's safe to use in other measures:
[Custom Sales] =
var __lastVisibleFY = max( 'Date'[Financial Year] )
return
CALCULATE (
[Sales],
keepfilters(
'Date'[Financial Year] = __lastVisibleFY
)
)
Also, for this to work you have to make sure that you do not slice by columns in the fact table, only through dimensions. What the above does is it grabs the last visible (in the current context) financial year from the Calendar and from the visible dates it only picks up the ones that are in this very last year, so [Sales] is calculated with all other filters on apart from maybe the Calendar in which only the dates from the last visible FY have been made active (within the current context, without overwriting any other filters that may exist on the Calendar).
Is this what you want? Please note that this measure does exactly what your original measure does.
Best
D
Thanks, yes agreed but still do not understand as to why the Product filter does not work with athe calculation. This is really strange behaviour.
Also do you suggest using keepfilters rather than using Filter?
What is the better way to share the pbi dashboard / data model in a forum like this ?
Yes Product filters all items in the SalesFact table in this case
The odd thing the calculation returns blank when selecting a product from a slicer, but as per example the calculation works when the Financial year is set to a fixed date ex 2020
It is difficult to know what is wrong with the information provided. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Is the Product column in the SalesFact table? If not, there could be a relationship issue or something going on.
Hi.
I updated the main topic.
There are no relationship issues in the model,. As per main topic the calculation seems to work fine when a fixed value is used in the calculation?
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
28 | |
11 | |
11 | |
10 | |
6 |