Crosstab IIF in expression value (1 Viewer)

p.perez

Registered User.
Local time
Today, 09:28
Joined
Jan 29, 2018
Messages
12
Hi everyone,
I have an issue creating a Cross Tab query and hope somebody can help.

I´ve uploaded the crosstab result and hidden personal data for privacy reasons.

Rows: Mail, Name, Last Name, Phone
Column: Product: ("1+1","2+1","2+2"...). These numbers are product names



Value: if any of these persons (rows) want a 1+1, 2+1 ... etc

What i´m trying to do:
Instead of showing the count in the value field, i want to show the name of the column header (product), in this case in the first column to show "1+1" instead of 1 or 2 or any number.

In the attachment there is a png file that is explained clearer.


In the next product( "2+1"), show "2+1" instead of 1...and so on

In Excel is easy to do because you put an IF(ISBLANK(G2);"";G$1) and so on.

But in Access i can´t do it and i have tried to have a calculated field for the value, but cant referrence to the "product".


Disclaimer: in the SQL code, "product" is tbl_tipologias.tipologia


Here is the code

Code:
TRANSFORM Count(tbl_busca_inversiones.inversion_vigente) AS CountOfinversion_vigente
SELECT tbl_personas.correo_persona, tbl_personas.nombre_persona, tbl_personas.apellido_persona, tbl_personas.telefono_persona
FROM tbl_personas INNER JOIN (tbl_busca_inversiones INNER JOIN tbl_tipologias ON tbl_busca_inversiones.tipologia = tbl_tipologias.Id) ON tbl_personas.Id_persona = tbl_busca_inversiones.persona
WHERE (((tbl_personas.correo_persona) Is Not Null) AND ((tbl_busca_inversiones.comuna)=1))
GROUP BY tbl_personas.correo_persona, tbl_personas.nombre_persona, tbl_personas.apellido_persona, tbl_personas.telefono_persona, tbl_busca_inversiones.comuna
PIVOT tbl_tipologias.tipologia;


Sorry for my English and thanks in advance,

Great forum!
Peivand Perez
 

Attachments

  • Crosstab.jpg
    Crosstab.jpg
    78.2 KB · Views: 207
Last edited by a moderator:

isladogs

MVP / VIP
Local time
Today, 17:28
Joined
Jan 14, 2017
Messages
18,211
Hi
Your post was moderated for some reason. Now approved,
I added code tags to make it easier to read.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:28
Joined
May 7, 2009
Messages
19,230
you can create another query based on the crosstab you have and put the expression there:

select correo, nombre, apellido, telefono, iif([1-1]=1,"1-1",[1-1]) as [1-1], ...
from qry_crosstabname
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:28
Joined
Oct 29, 2018
Messages
21,457
Hi. Just a guess but try it this way...
Code:
TRANSFORM Min(IIf(IsNull(tbl_busca_inversiones.inversion_vigente),"",tbl_busca_inversiones.inversion_vigente)) AS CountOfinversion_vigente

...
Hope it helps...
 
Last edited:

p.perez

Registered User.
Local time
Today, 09:28
Joined
Jan 29, 2018
Messages
12
Thanks a lot! arnelgp

It worked

Here is the code if can help

Code:
SELECT qry_busca_inversiones_Santiago_tags_mailchimp_crosstab.correo_persona, qry_busca_inversiones_Santiago_tags_mailchimp_crosstab.nombre_persona, qry_busca_inversiones_Santiago_tags_mailchimp_crosstab.apellido_persona, qry_busca_inversiones_Santiago_tags_mailchimp_crosstab.telefono_persona, IIf([1+1]>0,"1+1","") AS [exp1+1], IIf([2+1]>0,"2+1","") AS [exp2+1], IIf([2+2]>0,"2+2","") AS [exp2+2], IIf([Studio]>0,"Studio","") AS expStudio
FROM qry_busca_inversiones_Santiago_tags_mailchimp_crosstab;
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:28
Joined
May 7, 2009
Messages
19,230
you're welcome and goodluck!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:28
Joined
Oct 29, 2018
Messages
21,457
Hi. Glad to hear you got it sorted out. Good luck with your project.
 

p.perez

Registered User.
Local time
Today, 09:28
Joined
Jan 29, 2018
Messages
12
I also tried your suggestion, but i had a syntax problem.

Thanks anyway!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:28
Joined
Oct 29, 2018
Messages
21,457
I also tried your suggestion, but i had a syntax problem.

Thanks anyway!
Hi. No worries. It was just a guess anyway. Cheers!


PS. I wondered why you got a syntax error and I think I forgot a closing parens. I fixed the above code, for future reference. Thanks!
 

Users who are viewing this thread

Top Bottom