Forum Discussion
Monthly Usage Calculation
- Anonymous2 years ago
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] ) / _CountMonthHope 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.
- AdamD1232 years agoHelper I
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!