Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
My data contains a monthly data of products sales. I wish to create a measure that counts the number of products with sales above zero in the last 3 month.
I already created successfully a measure that sums up the sales in the last 3 months (by using DATESINPERIOD).
i tried this formula:
I would go with something like as follows. Create a var containing current date, then create a Summary table in a variable per product, with a column "lastthreemonths" using your [SalesLast3Months] measure. Then use COUNTX to filter out all rows with 0 as 'lastthreemonths' and return that value. Something like this (this is without intellisense so probably won't work right away ;))
Measure =
VAR curDate = MAX(ALLSELECTED(Sales[Date])) //returns 1/1/2019 for January, 1/2/2019 for Feb etc
VAR summaryTable = SUMMARIZE(Sales, Sales[Product], "Last3Months", CALCULATE([Sales], DATESINPERIOD(ALL(Sales[Date]), curDate, -3, MONTH)))
RETURN
COUNTX(FILTER(summaryTable, [Last3Months] > 0), [Product])
Kind regards
Djerro123
-------------------------------
If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.
Keep those thumbs up coming! 🙂
Proud to be a Super User!
does not work unfortunately ("DatesBetween and DatesInPeriod functions are only accepting date column refernce as a first argument")
i tried this one but it only worked sometimes and now it seems too heavy to load in a table visual:
Hmm that makes sense, sorry for not testing my proposed solution.
Is it possible to share your pbix? That will help a lot in creating the correct DAX for me. If you want, you can share the link via PM and I will have a look shortly 🙂
Kind regards
Djerro123
-------------------------------
If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.
Keep those thumbs up coming! 🙂
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
43 | |
20 | |
18 | |
16 | |
15 |
User | Count |
---|---|
49 | |
26 | |
22 | |
17 | |
16 |