Dataview "contains" help

Topic

Summary

User Requirement Specification (URS):
1.The Author field, in each Book page, is either a fileLink such as “[[King, Stephen|Stephen King]]” or an array of fileLinks such as [ “[[King, Stephen|Stephen King]]”, “[[Toliken, J.R.R.|J.R.R. Tolkien]]]” ].
2.The Alias field, in each Author page, is a string such as “Stephen King”.
3.The DQL10 is in an Author page such as [[dic_19620411]], [[Stephen King]], or [[King, Stephen]].
4.The fields mentioned above, such as the Author and Alias, are correct at all times.

  • How to compare the Author field, whch is a fileLink such as “[[King, Stephen|Stephen King]]” with the Alias field, whch is a string such as “Stephen King”?

Test

Summary
  • dataview: v0.5.55

Input

Summary

dictionary files: Books

Summary_B
  • Location: “100_Project/02_dataview/Q25_MetaFunction/Q25_test_data/Books”

folder: Some

  • filename : Some Book
---
Author: "[[King, Stephen|Stephen King]]"
Alias: "It"
Year: 1986
Medium: "Book"
Length: 1166
Rating: 10
DateStarted: 2021-06-02
DateFinished: 2021-06-30
Cover: "https://i.gr-assets.com/images/S/compressed.photo.goodreads.com/books/1327118909l/11381895.jpg"
Tags: "Horror"
Country: "US"
---



folder: Another_excluded

  • filename : Another Book
---
Author: "[[K , Stephen|Stephen K]]"
Alias: "It"
Year: 1986
Medium: "Book"
Length: 1166
Rating: 10
DateStarted: 2021-06-02
DateFinished: 2021-06-30
Cover: "https://i.gr-assets.com/images/S/compressed.photo.goodreads.com/books/1327118909l/11381895.jpg"
Tags: "Horror"
Country: "US"
---


folder: One_excluded

  • filename : One Book
---
Author: "[[King Test, Stephen|Stephen King Test]]"
Alias: "It"
Year: 1986
Medium: "Book"
Length: 1166
Rating: 10
DateStarted: 2021-06-02
DateFinished: 2021-06-30
Cover: "https://i.gr-assets.com/images/S/compressed.photo.goodreads.com/books/1327118909l/11381895.jpg"
Tags: "Horror"
Country: "US"
---


dictionary files: Authors

Summary_A
  • Location: “100_Project/02_dataview/Q25_MetaFunction/Q25_test_data/Authors”

folder: 04

[[dic_19620411]] = [[Stephen King]] = [[King, Stephen]]

  • filename : dic_19620411
---
Date: 1962-04-11

# the same as \[\[King, Stephen\]\]
Alias: "Stephen King"
Full Name: "Stephen Edwin King"
Years: "1947-"
Photo: "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e3/Stephen_King%2C_Comicon.jpg/330px-Stephen_King%2C_Comicon.jpg"
Tags: "Horror"
Country: "US"
cssClasses: cards, cards-cover, cards-2-3, table-max, max
---

### DQL10



  • filename : Stephen King
---
Date: 1962-04-01

# the same as \[\[King, Stephen\]\]
Alias: "Stephen King"
Full Name: "Stephen Edwin King"
Years: "1947-"
Photo: "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e3/Stephen_King%2C_Comicon.jpg/330px-Stephen_King%2C_Comicon.jpg"
Tags: "Horror"
Country: "US"
cssClasses: cards, cards-cover, cards-2-3, table-max, max
---

### DQL10



  • filename : King, Stephen
---
Date: 1962-04-01

Alias: "Stephen King"
Full Name: "Stephen Edwin King"
Years: "1947-"
Photo: "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e3/Stephen_King%2C_Comicon.jpg/330px-Stephen_King%2C_Comicon.jpg"
Tags: "Horror"
Country: "US"
cssClasses: cards, cards-cover, cards-2-3, table-max, max
---

### DQL10



folder: 12_excluded

  • filename : Stephen K
---
Date: 1962-12-01

Alias: "Stephen K"
Full Name: "Stephen Edwin K"
Years: "1947-"
Photo: "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e3/Stephen_King%2C_Comicon.jpg/330px-Stephen_King%2C_Comicon.jpg"
Tags: "Horror"
Country: "US"
cssClasses: cards, cards-cover, cards-2-3, table-max, max
---


  • filename : Stephen King Test
---
Date: 1962-12-07

Alias: "Stephen King Test"
Full Name: "Stephen Edwin King Test"
Years: "1947-"
Photo: "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e3/Stephen_King%2C_Comicon.jpg/330px-Stephen_King%2C_Comicon.jpg"
Tags: "Horror"
Country: "US"
cssClasses: cards, cards-cover, cards-2-3, table-max, max
---


DQL10_compare_a_fileLink_with_a_string_and_TABLE

Summary

Main DQL

Code Name Data type Group By Purposes Remark
DQL10
_compare_a_fileLink
_with_a_string
_and_TABLE
1.Author: (in Book pages)
1.1 a fileLink such as “[[King, Stephen|Stephen King]]”
1.2 an array of fileLinks such as [ “[[King, Stephen|Stephen King]]”, “[[Toliken, J.R.R.|J.R.R. Tolkien]]]” ]

2.Alias: (in Author pages)
a string such as “Stephen King”

3.file.name: an arbitrary string (for Author pages)
1.“King, Stephen”
2.“Stephen King”
3.“dic_19620411”
no 1.To filter by Author
2.To break up a list Author into each element OneAuthor
3.To filter by meta(OneAuthor).display
4.To display the result as a table
1.The fields such as the Author and Alias are correct at all times.

2.The DQL10 is in an Author page such as [[dic_19620411]], [[Stephen King]], or [[King, Stephen]].

Code DQL10_compare_a_fileLink_with_a_string_and_TABLE

Summary_code
title: DQL10_compare_a_fileLink_with_a_string_and_TABLE =>1.To filter by `Author` 2.To break up a list `Author` into each element `OneAuthor` 3.To filter by `meta(OneAuthor).display` 4.To display the result as a table
collapse: close
icon: 
color: 
```dataview
TABLE WITHOUT ID
      file.link AS "Book",
      this.file.link AS "current Author link", 
      meta(OneAuthor).display AS "display",
      this.Alias AS "current Author Alias",
      meta(OneAuthor) AS "meta(OneAuthor)"

FROM "100_Project/02_dataview/Q25_MetaFunction/Q25_test_data/Books"

WHERE Author
FLATTEN Author AS OneAuthor

WHERE meta(OneAuthor).display = this.Alias

```

Screenshots(DQL10):

in editing mode

when the page [[King, Stephen]] exists

The value of the meta(OneAuthor).path is “100_Project/02_dataview/Q25_MetaFunction/Q25_test_data/Authors/04/King, Stephen.md”.

when the page [[King, Stephen]] doesn’t exist

The value of the meta(OneAuthor).path is “King, Stephen”.


Reference

Summary

To get the display of a link: the P_display in the DQL10


2 Likes