Forum Discussion
MacarenaGB
5 years agoHelper II
Total is empty
I have some issues with my dax code because it doesn't sum the total, and after thinking it was because of a ISINSCOPE function, I get that the Switch I have inside doesn't sum either and I can't fin...
- 5 years ago
I resolved the issues finally.
First of all, I am not completely sure of what change fix the bug but, I created measures separated instead of using Variables in the same measure because I think it created some errors.After, I separated a little the code proposed by amitchandak (thank you!) to understand it better and here is the code:
VAR T_ProgramName = SUMMARIZE('Dim_Project Database', 'Dim_Project Database'[Project Type], 'Dim_Project Database'[Program Name]) VAR T_SubTotal= ADDCOLUMNS(T_ProgramName, "Col_Estimado", [Estimated_Resources], "Col_OtrosProyectos",SWITCH( [Program Name], "Non billable" , IF(PendingResources<=0, 0, IF( PendingResources >= NonBillingResourceCost, NonBillingResourceCost, PendingResources)), "Internal Project", IF(( PendingResources - NonBillingResourceCost) >0,PendingResources - NonBillingResourceCost,BLANK()), BLANK() ) ) VAR Total_Cost = SUMX(T_SubTotal, IF([Col_OtrosProyectos] = BLANK(), [Col_Estimado], [Col_OtrosProyectos])) RETURN Total_Cost
MacarenaGB
5 years agoHelper II
I resolved the issues finally.
First of all, I am not completely sure of what change fix the bug but, I created measures separated instead of using Variables in the same measure because I think it created some errors.
After, I separated a little the code proposed by amitchandak (thank you!) to understand it better and here is the code:
VAR T_ProgramName = SUMMARIZE('Dim_Project Database', 'Dim_Project Database'[Project Type], 'Dim_Project Database'[Program Name])
VAR T_SubTotal=
ADDCOLUMNS(T_ProgramName, "Col_Estimado", [Estimated_Resources], "Col_OtrosProyectos",SWITCH(
[Program Name],
"Non billable" , IF(PendingResources<=0, 0, IF( PendingResources >= NonBillingResourceCost, NonBillingResourceCost, PendingResources)),
"Internal Project", IF(( PendingResources - NonBillingResourceCost) >0,PendingResources - NonBillingResourceCost,BLANK()),
BLANK()
)
)
VAR Total_Cost = SUMX(T_SubTotal, IF([Col_OtrosProyectos] = BLANK(), [Col_Estimado], [Col_OtrosProyectos]))
RETURN Total_Costamitchandak
5 years agoSuper User
MacarenaGB , Thanks for posting the solution. Kudos to you....