Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data to columns #9

Open
LtnMax opened this issue Apr 4, 2019 · 2 comments
Open

Data to columns #9

LtnMax opened this issue Apr 4, 2019 · 2 comments

Comments

@LtnMax
Copy link

LtnMax commented Apr 4, 2019

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
Copy link
Owner

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
Copy link

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants