Forum Discussion
Question about creating Lines as totals _FRUSTRATION-
- 1 year ago
Hi quickbi
You can maintain a disconnected table that has separate rows for each category id in each line item
And use this measure to return the value for each P&L line
line value = CALCULATE( SUM(RevenueTable[Value]), TREATAS( SELECTCOLUMNS( FILTER( RevenueLines, RevenueLines[Operation] = "add" ), "Category ID", RevenueLines[Category ID] ), RevenueTable[Category ID] ) ) - CALCULATE( SUM(RevenueTable[Value]), TREATAS( SELECTCOLUMNS( FILTER( RevenueLines, RevenueLines[Operation] = "subtract" ), "Category ID", RevenueLines[Category ID] ), RevenueTable[Category ID] ) )The other approach is to create a measure for each line and return the values using a condition.
SWITCH ( SELECTEDVALUE ( 'table'[name] ), "Total Gross Profit", [Total GP Measure], "Total EBIT", [Total EBIT Measure] ) - 1 year ago
hi quickbi
That’s not how the table should be structured. In my example, each Category ID has its own row — they aren’t combined into a single row for each revenue line. There should also be an indicator showing whether the Category ID is an addition or a deduction. In the Query Editor, you can start by splitting the Category IDs. After that, you will need to transform the data so that each Category ID appears in its own row. Below is a sample custom column to split the category individually.
Text.Split([category id column], ",")This will create a column with each row containing a list of values. Expand them into new rows (there will be an expand icon next to the column name). Remove trailing and preceding spaces by right click the colum and selecting Trim or Clean.
Hi quickbi
You can maintain a disconnected table that has separate rows for each category id in each line item
And use this measure to return the value for each P&L line
line value =
CALCULATE(
SUM(RevenueTable[Value]),
TREATAS(
SELECTCOLUMNS(
FILTER(
RevenueLines,
RevenueLines[Operation] = "add"
),
"Category ID", RevenueLines[Category ID]
),
RevenueTable[Category ID]
)
)
-
CALCULATE(
SUM(RevenueTable[Value]),
TREATAS(
SELECTCOLUMNS(
FILTER(
RevenueLines,
RevenueLines[Operation] = "subtract"
),
"Category ID", RevenueLines[Category ID]
),
RevenueTable[Category ID]
)
)
The other approach is to create a measure for each line and return the values using a condition.
SWITCH (
SELECTEDVALUE ( 'table'[name] ),
"Total Gross Profit", [Total GP Measure],
"Total EBIT", [Total EBIT Measure]
)
Hi danextian
I modified the SQL and I created a string with the values that has to be included in a calculated condition using "in"
declaring formula field as a _Formula (variable) an including in a calculate formula
CALCULATE(
[PL_Amount],
REMOVEFILTERS('Mapping'),
'Mapping'[cashflowcategory] IN { _Formula }
What do you think?
- danextian1 year ago
Super User
hi quickbi
That’s not how the table should be structured. In my example, each Category ID has its own row — they aren’t combined into a single row for each revenue line. There should also be an indicator showing whether the Category ID is an addition or a deduction. In the Query Editor, you can start by splitting the Category IDs. After that, you will need to transform the data so that each Category ID appears in its own row. Below is a sample custom column to split the category individually.
Text.Split([category id column], ",")This will create a column with each row containing a list of values. Expand them into new rows (there will be an expand icon next to the column name). Remove trailing and preceding spaces by right click the colum and selecting Trim or Clean.
- v-dineshya1 year ago
Community Support
Hi quickbi ,
If danextian response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found his response helpful.
Thank you
- v-dineshya1 year ago
Community Support
Hi quickbi ,
If @danextian response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found his response helpful.
Thank you