Reputation: 23
Looking to take multiple rows of data and have them all listed in one column with Looker
Basic query would look like this:
SELECT booking_id, amount, type
FROM bookings
WHERE booking_id = 'Value'
It then spits out 4 columns with each one representing a different amount based on type. What I'm wanting to do is keep the booking ID in the first column and then have the different amounts and types go into their own column on the same row. Is this possible within Looker? Our company is making the move and most of us come from a SSMS background and are very confused.
Upvotes: 0
Views: 3347
Reputation: 1
You'll want to make sure you have 'amount' set up as a measure for this to work but I believe you just would want to have 'Booking ID' as a dimension, then pivot by the type and add the amount measure.
Upvotes: 0
Reputation: 39
You have concat 2 ways on Looker.
once a connected data source at that time have to create a field and write a formula which I have mentioned Below
= concat(your First(1st) field name + Your second(2nd) field name)
and after that check the process if a shows true then your formula is right.
-> If you don't understand the concept then refer to below Link
https://www.youtube.com/watch?v=YDqdaPcafgw&ab_channel=UmarTazkeer
Also, do a 2nd way using your database Source.
there write a query and create a runtime field at that time you have the same formula apply
concat(your First(1st) field name + Your second(2nd) field name)
and refresh a field on Looker Studio you do both ways.
Happy Coding!!!
Upvotes: -1
Reputation: 3964
You can combine dimension fields in LookML using concat. If its an integer and a string, cast the number data to a string first
dimension: combined_field_name {
type: string
sql: concat( CAST(${TABLE}.amount as string)), " " , ${TABLE}.type ) ;;
}
Upvotes: 0