Forum Discussion
Conditional Column based on other table
I have a table of registrations and a table of viewers. I would try to add them as a relationship but because of how the data is stored and the number of webinars, registrations, and viewers, I can't get it to work. So I'm wondering if I can find a way this way. (Tables simplified)
Registration:
| Webinar | |
| [email protected] | How to tie shoes |
| [email protected] | How to tie shoes |
| [email protected] | How to tie ties |
| [email protected] | How to tie ties |
Viewers:
| Watch start | Watch end | Webinar | |
| [email protected] | 11:12 | 11:15 | How to tie shoes |
| [email protected] | 11:10 | 11:20 | How to tie shoes |
| [email protected] | 11:20 | 11:30 | How to tie shoes |
| [email protected] | 12:10 | 12:30 | how to tie ties |
What I want in the registration table:
| Webinar | Watched | |
| [email protected] | How to tie shoes | Yes |
| [email protected] | How to tie shoes | Yes |
| [email protected] | How to tie ties | Yes |
| [email protected] | How to tie ties | No |
I think the idea would be:
For each row in the Registartions table:
- If a match exists between Registrations[email] and Viewers[email]
- If registrations[webinar_id] equals viewers[webinar_id]
- Set registrations[watched] to "Yes"
- Else set Set registrations[watched] to "No"
- If registrations[webinar_id] equals viewers[webinar_id]
Unless I'm missing something here?
Try adding this as a calculated column in your Registrations table.
Watched = VAR _ViewCount = CALCULATE ( COUNTROWS ( Viewers ), TREATAS ( CALCULATETABLE ( SUMMARIZE ( Registrations, Registrations[Email], Registrations[Webinar] ) ), Viewers[Email], Viewers[Webinar] ) ) RETURN IF ( _ViewCount > 0, "Yes", "No" )
3 Replies
- amitchandakSuper User
New column Registration =
var _1 = Maxx(filter(Viewers, Viewers[Email] =Registration[email]), Viewers[Email])
return
if(isblank(_1), "No", "Yes")
- dinoscool3Helper II
When I try to do this, I can't add in the registration email in the filter, it only lets me add in values from the viewers table.
- jdbuchanan71Super User
Try adding this as a calculated column in your Registrations table.
Watched = VAR _ViewCount = CALCULATE ( COUNTROWS ( Viewers ), TREATAS ( CALCULATETABLE ( SUMMARIZE ( Registrations, Registrations[Email], Registrations[Webinar] ) ), Viewers[Email], Viewers[Webinar] ) ) RETURN IF ( _ViewCount > 0, "Yes", "No" )