Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello Forum - I have a measure below that looks at the Order Date and the Due Date (both on my Orders table). Due Date is connected to my date table.
The formula says return the sum of the quantity ordered when the order date month is 2 months (or more) earlier than the due date month. The only problem is that it does not factor in the year. So, in the table below, the Sept 2019 order is not being picked up because the formula believes that 9 is greater than 5...which it is...but in this case I also need the Year to be taken into consideration. So, September (month 9) 2019 is of course less than May (month 5) of 2021.
Not sure how to modify the measure below to account for the year as well when the order date month is larger than the due month (but the order date year is in the previous year). Any suggestions?
Solved! Go to Solution.
@Anonymous , Try like
VAR vTable = CALCULATETABLE(Orders,ALL('Date Table'[Date]))
VAR nTable = FILTER(vTable,Orders[Order Date] <= eomonth(Orders[Due Date],-3)+1 ) // or use -2
VAR _Result = SUMX(nTable,[SumX of Qty Ordered])
RETURN
_Result
or
VAR vTable = CALCULATETABLE(Orders,ALL('Date Table'[Date]))
var _date = date(year(Orders[Due Date]), month(Orders[Due Date])-2, day(Orders[Due Date]))
VAR nTable = FILTER(vTable,Orders[Order Date] <= _date ) // or use -2
VAR _Result = SUMX(nTable,[SumX of Qty Ordered])
RETURN
_Result
Many Many thanks @amitchandak
Iused this version and it worked fine. Also, I had figured out another way that I think works, but yours is more elegant. My version is posted below yours.
@Anonymous , Try like
VAR vTable = CALCULATETABLE(Orders,ALL('Date Table'[Date]))
VAR nTable = FILTER(vTable,Orders[Order Date] <= eomonth(Orders[Due Date],-3)+1 ) // or use -2
VAR _Result = SUMX(nTable,[SumX of Qty Ordered])
RETURN
_Result
or
VAR vTable = CALCULATETABLE(Orders,ALL('Date Table'[Date]))
var _date = date(year(Orders[Due Date]), month(Orders[Due Date])-2, day(Orders[Due Date]))
VAR nTable = FILTER(vTable,Orders[Order Date] <= _date ) // or use -2
VAR _Result = SUMX(nTable,[SumX of Qty Ordered])
RETURN
_Result
Many Many thanks @amitchandak
Iused this version and it worked fine. Also, I had figured out another way that I think works, but yours is more elegant. My version is posted below yours.
User | Count |
---|---|
85 | |
81 | |
64 | |
53 | |
46 |
User | Count |
---|---|
101 | |
49 | |
42 | |
39 | |
38 |