Forum Discussion
Intersect function in Dynamic Matrix
- 5 years ago
Great explanation now 🙂
I haven't looked in detail at the logic for the code for [2 Visitas x Prospectos] but one thing does stand out. Why would you repeat
IF(ISBLANK(MonthEndStore),BLANK(),COUNTROWS(INTERSECT(TableStoreVisitors, TableWebVisitors )))11 times on the switch, if the result is exactly the same for each of the 11 options?? You can simplify the switch:
2 Visitas x Prospectos V2 = VAR IDMonth = SELECTEDVALUE(ID_Month[ID] ) - 1 VAR MonthWeb = MIN('Calendar'[Date]) VAR MonthStore = MAX('Calendar'[Date]) VAR MonthIniWeb = STARTOFMONTH(DATEADD(FILTER(LASTDATE('Calendar'[Date]), 'Calendar'[Date] = MonthStore ), IDMonth,MONTH)) VAR MonthEndStore = ENDOFMONTH(DATEADD(FILTER(LASTDATE('Calendar'[Date]), 'Calendar'[Date] = MonthStore ), IDMonth,MONTH)) VAR TableWebVisitors = CALCULATETABLE( SUMMARIZE(Data,Data[Client_ID]), Data[Channel] = "Web") VAR TableStoreVisitors = CALCULATETABLE( SELECTCOLUMNS( FILTER(Data, Data[Channel] = "Store"), "Visitors",Data[Client_ID]),DATESBETWEEN('Calendar'[Date],MonthIniWeb,MonthEndStore)) RETURN IF ( SELECTEDVALUE ( ID_Month[ID] ) IN GENERATESERIES ( 1, 11 ), IF (ISBLANK ( MonthEndStore ), BLANK (), COUNTROWS ( INTERSECT ( TableStoreVisitors, TableWebVisitors ) ) ) )Note that this is functionally equivalent to what you had. Now we can create another measure that uses the measure above and that will work at the totals.
2 Visitas x Prospectos V2 TOT = SUMX ( CROSSJOIN ( DISTINCT ( 'Calendar'[Period] ), DISTINCT ( ID_Month[ID] ) ), [2 Visitas x Prospectos V2] )Place this last measure in your matrix visual 3. You might want to change it for the result at the grand total.
See it all at work in the attached file.
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
I'm afraid do not understand what the code you show is. Is it the measure that goes into matrix 3? If so the code looks incomplete (no RETURN statement, etc...)
On top of that, I do not quite understand what the question is. You'll have to try and explain it a bit more.
It'd probably be best if you also attach the file with this latest version
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers