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.
Hello,
I need to calculate the sum of Sales for the particular date period.
I have two tables: Calendar and Historical Inventory (sales, by day and Item)
Sum up Period:
For example: if I have selected 2019-06-12, and TOC day for the item is 8, then Min date - 2019-06-12 and Max day - 2019-06-20
I wrote a DAX, but it brings the sum just for Min date:
Measure 2 = VAR mindate =MIN(Calendar[Date]) VAR maxdate = MIN(Calendar[Date])+AVERAGE('Historical Inventory'[TOC days]) RETURN CALCULATE( SUM('Historical Inventory'[Sales]); FILTER('Historical Inventory'; 'Historical Inventory'[Date]>=mindate && 'Historical Inventory'[Date]<=maxdate))
Maybe someone has any suggestions what's wrong with dax?
Hi @Anonymous ,
By my test, you need to add a ALL function in the measure. the following is my sample you can have a try.
I have two tables. The table “Calendar” is a calendar table. And there is a many-to-one between two tables.
Calendar = CALENDARAUTO()
Measure = VAR mindate =MIN(Calendar[Date])
VAR maxdate = MIN(Calendar[Date])+AVERAGE('Historical Inventory'[TOC days])
RETURN
CALCULATE(
SUM('Historical Inventory'[Sales]),
FILTER(ALL('Historical Inventory'),
'Historical Inventory'[Date]>=mindate
&& 'Historical Inventory'[Date]<=maxdate))
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks @v-xuding-msft
It works with dates, but how I should correct the DAX if I want to see information by Item?
Hi @Anonymous ,
Do you mean filter by item using the slicer? If so, it still calculate the sum in dynamic period when I add the slicer of items.
You can download my sample to reference. If this is not your expected output, please share more details.
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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 |
---|---|
114 | |
99 | |
83 | |
70 | |
60 |
User | Count |
---|---|
150 | |
115 | |
104 | |
89 | |
65 |