Forum Discussion
Need help, how to put different expression each rows...
Is it possible to apply a different expression to each row of a table I created in PowerBI?
I want to put the sum of the other columns for each row in one column.
That is, the first row of column A is the total value of column C, the second row of column A is the total value of column D, and the third row is the total value of column E. In other words, the first row of column A is the total value of column C, the second row of column A is the total value of column D, and the third row is the total value of column E
At the moment, when I create a column, I can only get the sum of one column and all the rows will have the same number.
Can someone please help me?
- Anonymous6 years ago
HI Anonymous,
Any fields in your table with unique values? If this is a case, you can write a measure formula with switch function to check that row as 'index' and list all these cases with specific calculation expressions.
For example:
Measure = SWITCH ( SELECTEDVALUE ( 'Table'[Key] ), "key1", 'formula1', "Key2", 'formula2', "Key3", 'formula3', "Key4", 'formula4', "Key5", 'formula5', "Key6", 'formula6', "formula for other scenarios" )Regards,
Xiaoxin Sheng
3 Replies
- judspudSolution Supplier
Hi Anonymous
Do they specifically need to be columns?
You could create them as measures
Hope this helps
Thanks,
George
- amitchandakSuper User
Can you share sample data and sample output.
You can use union and summarize to have a table like
union (
summarize(Table,"Measure1",[Measure1]),
summarize(Table,"Measure2",[Measure2])
summarize(Table,"Measure3",[Measure3])
summarize(Table,"Measure4",[Measure4])
)If you only want to display measure on column 1. In Matrix you have option Show on Row, That will move you measures in a column rows wise
- AnonymousNot applicable
HI Anonymous,
Any fields in your table with unique values? If this is a case, you can write a measure formula with switch function to check that row as 'index' and list all these cases with specific calculation expressions.
For example:
Measure = SWITCH ( SELECTEDVALUE ( 'Table'[Key] ), "key1", 'formula1', "Key2", 'formula2', "Key3", 'formula3', "Key4", 'formula4', "Key5", 'formula5', "Key6", 'formula6', "formula for other scenarios" )Regards,
Xiaoxin Sheng