Forum Discussion
DAX Filter not working as expected
- Anonymous2 years ago
Hi JS_UNI4C
Greg_Deckler Thank you very much for your prompt reply, please allow me to share some content here.
Based on the code you provided, it looks like you have three tables. The cause of your problem, I think, is that your tables don't have the right relationship with each other.
It is best to have a relationship between Calendar for sales and ValueEntries. For example, if both tables contain order ids, you can use the order ids to create relationship.
If you cannot create a relationship, you need MonthYearNum and Year in ValueEntries. For example:
"ValueEntries"
"Calendar slicer"
Create measures.
SalesSum = var SalesSumCM = SUMX(filter(ValueEntries,ValueEntries[Document_Type] = "Sales Credit Memo"),ValueEntries[Sales_Amount_Actual]) var SalesSumINV = SUMX(filter(ValueEntries,ValueEntries[Document_Type] = "Sales Invoice"),ValueEntries[Sales_Amount_Actual]) RETURN SalesSumCM + SalesSumINVMTD = IF( ISFILTERED('Calendar slicer'[Year]) && ISFILTERED('Calendar slicer'[MonthYearNum]), SUMX( FILTER( ALL('ValueEntries'), 'ValueEntries'[Year] = MAX('Calendar slicer'[Year]) && 'ValueEntries'[MonthYearNum] = MAX('Calendar slicer'[MonthYearNum]) ), 'ValueEntries'[SalesSum] ), SUMX( FILTER( ALL('ValueEntries'), 'ValueEntries'[Year] = YEAR(TODAY()) && 'ValueEntries'[MonthYearNum] = MONTH(TODAY()) ), 'ValueEntries'[SalesSum] ) )YTD = SUMX( FILTER( ALL('ValueEntries'), 'ValueEntries'[Year] = MAX('Calendar slicer'[Year]) && 'ValueEntries'[MonthYearNum] <= MAX('Calendar slicer'[MonthYearNum]) ), 'ValueEntries'[SalesSum] )Here is the result.
If you're still having problems, provide some dummy data and the desired outcome. It is best presented in the form of a table.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
JS_UNI4C It's easily adaptable. You can watch the video here on how to do it with just a Date column:
Thanks Gary but I am simply struggling too much to adapt it. You are far more knowledgeable than me when it comes to this so for you it may seem simple but for me it isn't. Your videos have too much prior knowledge required and I'm afraid I don't have the luxury of time to watching all your videos and then still try and figure them out. I watched the above video but you use helper columns as you put it yourself which means I have to go modify my data and I am trying to stear clear of that. You also have some measures in there which are not shown e.g. [Internet sales].
I apologise, I don't meant to sound rude, but I don't think your suggestion is what I am after. I was hoping someone could tell me what I am doing wrong with my DAX instead of having to try create what feels like an entire new file.