fredrikheden / summarytable

Summary Table Custom Visual for Power BI
33 stars 17 forks source link

Data to columns #9

Open LtnMax opened 5 years ago

LtnMax commented 5 years ago

Hi!

I am a complete newby in writing any code at all. I understand, how to format things in your visual, but I have no Idea how to split data into columns:

1) I have a data table of three columns: [Account_name], [Data], [Amount] 2) Respectively I add them all as fields to the visual 3) After that I have the following columns code (see below) 4) What I want is to display [Amount] depending on the [Date]. I thought is should be done via "CalculationFormula" in the "columns" part, but I failed all the attempts.

Thank you!

{ "headerStyle": "border-bottom:1px;border-bottom-color:#eee;border-bottom-style:solid", "rowStyle": "text-align:left", "width": 150, "type": "RowHeader", "refName": "[Account_name]", "title": "", "calculationFormula": "", "format": "" }, { "headerStyle": "border-bottom:1px;border-bottom-color:#eee;border-bottom-style:solid", "rowStyle": "", "width": 150, "type": "Calculation", "refName": "[Amount]", "title": "2017", "calculationFormula": "[Amount]", "format": "#,#" }, { "headerStyle": "border-bottom:1px;border-bottom-color:#eee;border-bottom-style:solid", "rowStyle": "", "width": 150, "type": "Calculation", "refName": "[Amount]", "title": "2018", "calculationFormula": "[Amount]", "format": "#,#" } ]

fredrikheden commented 5 years ago

Hi, In order to use year as columns you need to first create a separate measure for each year using DAX, and then use those measures in separate columns. / Fredrik

lucaliberty commented 5 years ago

Hi Fredrik

I'm also completely new to Power BI and I think I'm having a similar issue to LtnMax. When I put the relevant fields into the field list - EOM (Year) and Revenue - and press 'Generate template from field list', the table created has the years as separate columns, and only one row (Revenue).

I'd like to flip this so the years are rows and the Revenue is a column. Below is some code I have written to try and fix this. This, however, shows the years along the top only (no revenue at all) please could you help me fix it?

Thanks Luca

{ "columns": [ { "headerStyle": "text-align:left", "rowStyle": "text-align:left", "width": 100, "type": "RowHeader", "refName": "[Revenue]", "title": "", "formula": "[Revenue]", "format": "" }, { "headerStyle": "text-align:left", "rowStyle": "text-align:left", "width": 100, "type": "RowHeader", "refName": "[EOM (Year)]", "title": "2019", "formula": "[2019]", "format": "" }, { "headerStyle": "text-align:left", "rowStyle": "text-align:left", "width": 100, "type": "RowHeader", "refName": "[EOM (Year)]", "title": "2020", "formula": "[2020]", "format": "" }, { "headerStyle": "text-align:left", "rowStyle": "text-align:left", "width": 100, "type": "RowHeader", "refName": "[EOM (Year)]", "title": "2021", "formula": "[2021]", "format": "" } ], "rows": [ { "title": "Revenue", "formula": "[Revenue]", "rowStyle": "", "visible": true, "cellRowHeaderStyle": "", "cellRowDataStyle": "" } ], "headerRow": { "rowStyle": "" }, "displayAllRows": false }