Forum Discussion
Create Counter for Each Value in a Specific Columns as New Columns
Hi community,
I stucking in a problem for 2 days long. I searched for examples here but I don't even know the correct words to express it properly.
I made these two tabels to show my need. I have a table like so:
| Date | Categories |
| 05/07/2017 | Category1 |
| 06/07/2017 | Category1 |
| 06/07/2017 | Category2 |
| 07/07/2017 | |
| 07/07/2017 | Category1 |
| 08/07/2017 | Category3 |
| 09/07/2017 | |
| 10/07/2017 | Category1 |
| 10/07/2017 | Category2 |
| 10/07/2017 | Category3 |
And I need to quantify the categories in each date, which means this:
| Date | Category1 | Category2 | Category3 | "Null" |
| 05/07/2017 | 1 | |||
| 06/07/2017 | 1 | 1 | ||
| 07/07/2017 | 1 | 1 | ||
| 08/07/2017 | 1 | |||
| 09/07/2017 | 1 | |||
| 10/07/2017 | 1 | 1 | 1 |
It's simples to illustrate, but could not reach any solved question with similar in my searches.
Thanks for your help!
Regards!
- Anonymous8 years ago
This was cool,
You should to pivot the Category column.
This is the new script:let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDVNzDXNzIwNFfSUXJOLElNzy+qNFSK1QFKmZEmZQSRMkeSwhRBM8cCi5QxRMoS3RxDA5zmYJUywi0FtCIWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t, Categories = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Categories", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","","""Null""",Replacer.ReplaceValue,{"Categories"}),
#"Duplicated Column" = Table.DuplicateColumn(#"Replaced Value", "Categories", "Categories - Copy"),
#"Pivoted Column" = Table.Pivot(#"Duplicated Column", List.Distinct(#"Duplicated Column"[#"Categories - Copy"]), "Categories - Copy", "Categories", List.Count)
in
#"Pivoted Column"I deserve a big congratulation, so I congratulate myself ... Well done ...; D
10 Replies
- AnonymousNot applicable
Hi leandromaiaf,
It's quite simple. See the image I've attached.
Tell us if works for you.
- AnonymousNot applicable
Thanks for you help!
Yes, thats exactly what I need, but is it possible to manipulate it in query editor?
Or maybe create a new table in the report itself?
- BobBI
Resolver III
i created 2 duplicate entries to show the result. Create a summary table and use it to create visual.
SUMMARIZE(categories, categories[Date], categories[Categories], "Count",count(categories[Date]) )Hope this helps,
SS