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 Everyone,
I'm trying to count number of invoices of this year and last year i have one table invoice which containes everything but the results i get are the same here is the dax formulas i'm using:
This year total invoices = CALCULATE(COUNT(invoice[Type]);invoice[Type] = "Accepted")
Last year total invoices = CALCULATE(COUNT(invoice[Type]);invoice[Type] = "Accepted"; SAMEPERIODLASTYEAR(invoice[date].[Date]))
Results:
Solved! Go to Solution.
Hi @v-jianhe-msft,
Thank you very much for this reply i will try your suggestion, but i just want you to know that i solved the problem using Calendar table as follow:
Calendar = CALENDAR(MIN(invoice[date]);MAX(invoice[date]))
Last year total invoices = CALCULATE ( COUNT(invoice[Type]),invoice[Type] = "Accepted"; DATESBETWEEN(invoice[date];DATE (YEAR(MIN(invoice[date]))-1; MONTH (MIN(invoice[date])); DAY(MIN(invoice[date])));DATE(YEAR(MAX(invoice[date]))-1; MONTH (MAX(invoice[date]));DAY(MAX(invoice[date])))) )
This year total invoices = CALCULATE(COUNT(invoice[Type]),invoice[Type] = "Accepted";DATESBETWEEN(invoice[date];MIN(Calendar[Date]);MAX(Calendar[Date])))
In the date slicer i used the Calendar date and it works perfectly.
Hi,
How is your table like? Have you, at least, one record for any possible date in the two years? If not, the Intelligence functions can't work as expected.
And, if you meet this condition, you could try with:
Last year total invoices = CALCULATE(COUNT(invoice[Type]),invoice[Type] = "Accepted", SAMEPERIODLASTYEAR(invoice[date]),ALLEXCEPT(invoice,invoice[date]))
Best Regards,
Henry
Hi @v-jianhe-msft,
I've tried your solution but it shows the same results for all the operators. i've only changed this SAMEPERIODLASTYEAR(invoice[date].[Date])
CALCULATE(COUNT(invoice[Type]),invoice[Type] = "Accepted", SAMEPERIODLASTYEAR(invoice[date].[Date]),ALLEXCEPT(invoice,invoice[date]))
Hi @v-jianhe-msft,
Thank you very much for this reply i will try your suggestion, but i just want you to know that i solved the problem using Calendar table as follow:
Calendar = CALENDAR(MIN(invoice[date]);MAX(invoice[date]))
Last year total invoices = CALCULATE ( COUNT(invoice[Type]),invoice[Type] = "Accepted"; DATESBETWEEN(invoice[date];DATE (YEAR(MIN(invoice[date]))-1; MONTH (MIN(invoice[date])); DAY(MIN(invoice[date])));DATE(YEAR(MAX(invoice[date]))-1; MONTH (MAX(invoice[date]));DAY(MAX(invoice[date])))) )
This year total invoices = CALCULATE(COUNT(invoice[Type]),invoice[Type] = "Accepted";DATESBETWEEN(invoice[date];MIN(Calendar[Date]);MAX(Calendar[Date])))
In the date slicer i used the Calendar date and it works perfectly.
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 |
---|---|
111 | |
94 | |
83 | |
67 | |
59 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |