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.
Hi
I am trying to calculate sales based on the maximum invoice period, in case someone chooses multiple periods. here is my formula and it is not working. Any help will be appreciated.
Solved! Go to Solution.
Without going into whether there are any other issues with this approach, to get around the problem you have raised you'd just need to put it into a variable:
Sales = var filterDate = max(Query1[InvoicePeriod]) RETURN CALCULATE( sum(Query1[SalesValue]); Query1[InvoicePeriod] = filterDate )
You'll also need to specify what the filter condition is. I've assumed you want records based on that date. However you could use <= if you wanted to get all records on or before.
I'd suggest creating a date table and having the slicer be based on that date table. Then, for variable filterdate, do the max on the DateTime instead.
Without going into whether there are any other issues with this approach, to get around the problem you have raised you'd just need to put it into a variable:
Sales = var filterDate = max(Query1[InvoicePeriod]) RETURN CALCULATE( sum(Query1[SalesValue]); Query1[InvoicePeriod] = filterDate )
You'll also need to specify what the filter condition is. I've assumed you want records based on that date. However you could use <= if you wanted to get all records on or before.
Hi Ross
Thank for replying.
However, I am noticing that if the FilterDate does not have values for that month, the value that is being produced is for other months.
For example, suppose the user selects Jan and Feb (represented as number 201801 and 201802). if Feb has no sales values, the result returned is for Jan. I do not want that. I prefer that the value that comes through = 0 or blank
I'd suggest creating a date table and having the slicer be based on that date table. Then, for variable filterdate, do the max on the DateTime instead.
Yes it worked thank you
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 |
---|---|
110 | |
94 | |
81 | |
66 | |
58 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |