This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hello,
I have a calculation which is working for some lines but not otherS, I was hoping someone could point me the right direction as to where I have gone wrong?
I am trying to work out an average monthly usage per line, since January 2022. For example PP0002, we have used 511x (Qty of postings) since the beginning of 2022. This equates to an average of 18.25 (511 / 28 (completed months) = 18.25).
Whereas PP0001, we have used 4x (Qty of postings) since the beginning of 2022. This equates to an average of 0.14 (4 / 28 = 0.142587) but this is showing as 1.33?
Any help is greatly appreciated.
Kind regards,
Adam
Solved! Go to Solution.
Hi @AdamD123
I speculate the issue can be caused by the code:
DATEDIFF(MIN (ItemLedgerEntries[Posting_Date]),MAX (ItemLedgerEntries[Posting_Date]),month)
Maybe you can try to output the result for just this piece of code and see if it's 28.
If not, please try this:
MEASURE =
VAR _CountMonth =
CALCULATE (
DATEDIFF (
MIN ( ItemLedgerEntries[Posting_Date] ),
MAX ( ItemLedgerEntries[Posting_Date] ),
MONTH
),
ALLSELECTED ( ItemLedgerEntries )
)
RETURN
SUM ( ItemLedgerEntries[Quantity] ) / _CountMonth
Hope it helps,
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @AdamD123
I speculate the issue can be caused by the code:
DATEDIFF(MIN (ItemLedgerEntries[Posting_Date]),MAX (ItemLedgerEntries[Posting_Date]),month)
Maybe you can try to output the result for just this piece of code and see if it's 28.
If not, please try this:
MEASURE =
VAR _CountMonth =
CALCULATE (
DATEDIFF (
MIN ( ItemLedgerEntries[Posting_Date] ),
MAX ( ItemLedgerEntries[Posting_Date] ),
MONTH
),
ALLSELECTED ( ItemLedgerEntries )
)
RETURN
SUM ( ItemLedgerEntries[Quantity] ) / _CountMonth
Hope it helps,
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello @Anonymous ,
Thank you for your reply and help, your code seems to have worked! I can't say I understand it (my lack of Power BI knowledge) but it is certainly showing the correct figures, which I would expect to see when manually calculating.
Thank you ever so much for the help!
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 29 | |
| 28 | |
| 25 | |
| 20 | |
| 14 |
| User | Count |
|---|---|
| 53 | |
| 47 | |
| 27 | |
| 20 | |
| 19 |