Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
bharathkamath28
Contributor III
Contributor III

Calculated dimension on two fields

Hi All/@sunny_talwar 

I am not able to achieve this scenario.

I have a bar chart.

My calculated condition is 

=if( count(distinct Month)>2, Month, Year)

tried with aggr() function

= if ( aggr (count(distinct Month)>2 , ID), Month, Year)

Still not working for me.

Please any one help me on this.

 

Thanks,

Labels (1)
1 Solution

Accepted Solutions
tresesco
MVP
MVP

Try this:

=if ( $(=count(distinct Month)>2) , [Month], [Year])

View solution in original post

9 Replies
Surya
Creator II
Creator II

Hello ,

I'm Not getting you exact one But simply do

if(not wildmatch(month,1,2),month,year)

tresesco
MVP
MVP

May be this?

= aggr (If(count(distinct Month)>2 , ID), Year,ID)

bharathkamath28
Contributor III
Contributor III
Author

No, its not working for me.

I have to calculate the (distinct month) first.

Based on this (distinct month) value, i have to pass either Month or Year in the dimension for Bar Chart

tresesco
MVP
MVP

Could you explain your expected output with a sample data set?

bharathkamath28
Contributor III
Contributor III
Author

I have attached the sample data.

Suppose if i select ID=2, then bar chart dimension should be Year. 

if i select ID=3 and ID=1 then bar chart dimension should be Month.

I have to include count(distinct Month) in my calculation --> this is the key.

bharathkamath28
Contributor III
Contributor III
Author

Please check this sample data

tresesco
MVP
MVP

Try this:

=if ( $(=count(distinct Month)>2) , [Month], [Year])

bharathkamath28
Contributor III
Contributor III
Author

Thanks!!.. This is working fine.

I got the other way for this scenario 

By creating variable vCount=if(count(distinct Month)>12,1,0)

dimension= pick(match($(vCount),1,0),Year,Month)

bharathkamath28
Contributor III
Contributor III
Author

Hi @tresesco 

With the below expression i see the formula in the selection bar.

bharathkamath28_0-1602139326414.png

 

=if ( $(=count(distinct DateA)>12) , Year(DateA), date(DateA,'DD:MMM:YYYY'))

 

How to resolve these kind of issues.

 

Thanks,