Forum Discussion
DAX Formula
- 2 years ago
Hi PBI_37,
I was able to return the correct value, if I understood your intention.
Try this measure instead for your Total Sales with Flag:
Total Sales with Flag = VAR YearMonth = SUMMARIZE ( 'Calendar', 'Calendar'[Year], 'Calendar'[Month Name] ) VAR SalesbyMonth = ADDCOLUMNS ( YearMonth, "@Flag", [Flag] ) VAR FilteredYearMonth = FILTER ( SalesbyMonth, [@Flag] = "X" ) VAR Result = SUMX ( FilteredYearMonth, [Total Sales] ) RETURN ResultThe reason mine works and yours doesn't is because when you put your flag in the filter condition in your measure, it is looking at every sales line and checking if the sales on that order are greater than 4,000. Mine forces it to make the check at the year/month level (like you have in your matrix).
----------------------------------
If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)P.S. Need a more in-depth consultation for your Power BI data modeling or DAX issues? Feel free to hire me on Upwork or DM me directly on here! I would love to clear up your Power BI headaches.
- 2 years ago
Assez facile,
- 2 years ago
Hi,
This measure works
Total Sales with Flag = CALCULATE([Total Sales],FILTER(VALUES('Calendar'[Month Name]),[Total Sales]>4000))
For your reference.
Please try this measure below.
Total Sales with Flag = CALCULATE(SUM('Sales'[Total Sales]), FILTER(Sales, 'Sales'[Flag] = "X"))