Forum Discussion
Please help with Wrong total
As you see in the first table I need to only include the Min([Engagement_Date]) , I did it but my total keep coming back wrong and istead of 88, it shows 16 in my dashboard. can you help ?
VAR Min_Date = MIN('Calendar Service'[YearMonth])
VAR Max_Date = MAX('Calendar Service'[YearMonth])
VAR _gp = MAX('Group Dim'[GP])
VAR _ACTIVE_ID = GROUPBY(FILTER(‘Table’,([ENR_DT]>= Min_Date && [ENR_DT]<= Max_Date) && ([ENGAGED_DT]>= Min_Date && [ENGAGED_DT]<= Max_Date) && ‘Table’[GP]=_gp && [ID] <> "0" ),’Table’[ID])
VAR _MIN_ENG_DT= CALCULATE(MINX( SUMMARIZE(FILTER(‘Table’,([ENR_DT]>= Min_Date && [ENR_DT]<= Max_Date) && ([ENGAGED_DT]>= Min_Date && [ENGAGED_DT]<= Max_Date) &&’Table’[GP]=_gp && [ID] <> "0" ), ‘Table’[ID],"_Min", Min(‘Table’[ENG_Date])),[_Min]))
VAR _TempUnion=
CALCULATETABLE(
GROUPBY(
SUMMARIZE(FILTER(‘Table’, ‘Table’[ID] IN _ACTIVE_ID && ([ENR_DT]>= Min_Date && [ENR_DT]<= Max_Date) && ([ENGAGED_DT]>= Min_Date && [ENGAGED_DT]<= Max_Date) && ‘Table’[GP]=_gp), [ID], "_DEN", 0, "_NUM", 0, "_MBR_MOS", CALCULATE(SUMX(‘Table’,[MOS]),’Table’[ENG_Date] = _MIN_ENG_DT)) [ID] , "_MOS", SUMX(CURRENTGROUP(),[MOS])))
RETURN
CALCULATE(SUMX(_TempUnion,[MOS]))
wront total:
7 Replies
- Greg_Deckler
Community Champion
NilR First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e
This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376
Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907
Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8- NilR
Post Patron
Thanks Greg_Deckler ! I tried your solution before, but I could not get it working 😞
- Greg_Deckler
Community Champion
NilR Well, it's a pretty complex measure but maybe try this:
Measure Total = VAR __Table = ADDCOLUMNS( SUMMARIZE('Table', [ID], [ENGAGED_DT]), "__Value", [Current Measure] ) VAR __Result = IF( HASONEVALUE('Table'[ID]), [Current Measure], SUMX(__Table, [__Value])) RETURN __Result
- NilR
Post Patron
parry2k I use below variable to get the Min of date for each ID.
VAR _MIN_ENG_DT= CALCULATE(MINX( SUMMARIZE(FILTER(‘Table’,([ENR_DT]>= Min_Date && [ENR_DT]<= Max_Date) && ([ENGAGED_DT]>= Min_Date && [ENGAGED_DT]<= Max_Date) &&’Table’[GP]=_gp && [ID] <> "0" ), ‘Table’[ID],"_Min", Min(‘Table’[ENG_Date])),[_Min]))
I realized it is not working properly and this is the reason that returns wrong total!