英文:
Show a column unique text values as tick labels for Y-axis instead of numbers?
问题
我想以以下方式在图表中显示下面的两列数据。第一列应该是X轴的值,第二列应该是Y轴的唯一刻度标签。所以基本上是一个时间线图,针对特定日期有多个绘图点。
我找不到任何选项来更改/修改显示在Y轴上的缩放点,以显示第二列的唯一文本值。
在Google表格中是否有可能呢?
所需结果:
habit3 x x
habit2 x x
habit1 x x
2023-04-10 2023-04-12 2023-04-17 2023-04-19
我已经想到了这个(但我想要反过来 - 切换两个轴):
当我尝试转置版本时,我收到了“无效类型”错误:
更新:我已经接近所需的结果 - 在左侧应用图例:
如果只有这是可能的(但我怀疑):
英文:
I want to display the below 2 columns in a chart in the following way. The first column should be the values for X axis, the second column should be the unique tick labels for Y axis. So basically a timeline chart with multiple draw points for a particular date.
I can't find any option to change/modify the scaling points displaying the Y-axis to the unique text values of second column.
Is it possible in Google-sheets somehow?
date | habit |
---|---|
2023-04-10 | habit1 |
2023-04-10 | habit2 |
2023-04-12 | habit3 |
2023-04-17 | habit1 |
2023-04-17 | habit3 |
2023-04-19 | habit2 |
Wanted result:
habit3 x x
habit2 x x
habit1 x x
2023-04-10 2023-04-12 2023-04-17 2023-04-19
I've come up with this(but I want the other way around - switching the 2 axes):
When I tried the transpose version - I've got an Invalid type error:
Update: I've come to this close to the wanted result - applying Legend on the left:
If only this was possible(but I doubt it):
答案1
得分: 2
你可以尝试这个,假设数据在名为Data的标签中,并且在第1行开始的A列和B列中。
在一个全新的标签中,将这个公式放在A1单元格中...
=转置(QUERY({Data!A1:B},"选择 Col1,COUNT(Col1) 按 Col1 分组 pivot Col2 label Col1'Habits'",1))
英文:
You can try this assuming that the data is in a tab called Data and is in columns A and B starting in row 1.
On a completely brand new tab, put this formula in cell A1...
=TRANSPOSE(QUERY({Data!A1:B},"select Col1,COUNT(Col1) group by Col1 pivot Col2 label Col1'Habits'",1))
答案2
得分: 2
这是一个以公式方式执行的替代方法,以实现您所需的结果
=LET(row_,UNIQUE(TOROW(A2:A,1),1),col_,SORT(UNIQUE(TOCOL(B2:B,1)),1,),
{{col_;IF(,,)};{MAKEARRAY(COUNTA(col_),COUNTA(row_),LAMBDA(r,c,INDEX(IF(IFNA(XMATCH(INDEX(col_,r)&INDEX(row_,,c),B:B&A:A)), "✔", ))));row_}})
- 这个公式是动态的,将随着新数据不断添加到列A、B中而“向右和向下扩展”。
英文:
Here's an alternate approach doing it formulaic way to achieve your wanted result
=let(row_,unique(torow(A2:A,1),1),col_,sort(unique(tocol(B2:B,1)),1,),
{{col_;if(,,)},{makearray(counta(col_),counta(row_),lambda(r,c,index(if(ifna(xmatch(index(col_,r)&index(row_,,c),B:B&A:A)),"✔",))));row_}})
- the formula is dynamic and will
expand to right and downwards
as new data keeps being added to the raw data in columns A,B
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论