Forum Discussion
Urgent: Inconsistent Row Totals in Power BI Matrix Visual with Custom Logic for Start and End Month
- 1 year ago
This here is a forum where users help users, time permitting. For urgent requests contact a Microsoft partner near you.
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523 - 1 year ago
Materialize your measure.
- Anonymous1 year ago
Hi lbendlin I've slightly adjusted the logic and its working fine for me now:
Units_in_month =VAR curr_month= MAX('Calendar Table'[Year_Month])VAR days_in_month_ratio=DIVIDE(CALCULATE(COUNTROWS('Slicer'),Slicer[Year_Month]=curr_month),COUNTROWS('Calendar Table'),0)VAR TotalUnits = SUM('Master-Data'[UNIT])VAR StartDate = MIN('Slicer'[Date])VAR DaysInMonth = DAY(EOMONTH(StartDate,0)) -- Number of days in Start DateVAR CurrentDay = DAY(StartDate) -- Current dayVAR difference = ABS(DaysInMonth - CurrentDay)RETURN IF(MIN('Slicer'[Year_Month])=curr_month && CurrentDay<>1,TotalUnits / DaysInMonth * difference,days_in_month_ratio * TotalUnits)Also, adjusted calendar table logic because if we have multiple years of data and then ,if we choose latest year in the date filter then logic for last month column is not working as expected. Just mentionig this here if in case somebody else searching for the soltuion on it..Calendar Table = CALENDAR(Min('Master-Data'[Date]),EDATE(Max('Master-Data'[Date]),12))Thanks for your co-ordination on acheiving the solution lbendlin