Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Robin9700
Helper I
Helper I

How to calculate values with different formula for each row?

Hi All,

 

I would like to (manually) add a table to my dataset which calculates different values, with different criteria for each row. What I need is a simple table, with 9 rows and 2 columns, looking like this (simple example):

Label                     Calculated value
Labour costs         Calculate ( SUM( [table 1]column 1 , [table1]column 2 = 4000)
Ads/marketing      Calculate ( SUM( [table 1]column 1) , Filter([table1]column 2 = 4100), Filter([table1]column 2 = 4110) )
IT-dept.                 Calculate ( SUM( [table 1]column 1) , Filter([table1]column 2 = 1410), Filter([table1]column 2 = 2500) )
etc.

 

Is it at all possible to calculate values like this? When adding a column or measure, I only see the possibility to apply 1 formula to all rows, but obviously that is not what I want. Another possibility is creating 9 mini-tables using aforementioned solution, but there has to be a better way, right?

 

Any advice would be appreciated!

 

PS please note that table1 is a different table. There is no relationship possible between these tables.

 

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @Robin9700 ,

In my opinion,you need to create a new label table :

vluwangmsft_0-1645153861500.png

 

And if you want to create a new column,test like below:

newcolumn=if([Label[label]="Labour costs",
               Calculate ( SUM( [table 1]column 1 , [table1]column 2 = 4000),
          IF([Label[label]="Ads/marketing",
Calculate ( SUM( [table 1]column 1) , Filter([table1]column 2 = 4100),Filter([table1]column 2 = 4110) ),
       IF([Label[label]="IT-dept.", Calculate ( SUM( [table 1]column 1) , Filter([table1]column 2 = 1410), Filter([table1]column 2 = 2500)),BKANK()))

And if you want to create a new measure,test like below:

newcolumn=if(max([Label[label])="Labour costs",
               Calculate ( SUM( [table 1]column 1 , [table1]column 2 = 4000),
          IF(max([Label[label])="Ads/marketing",
Calculate ( SUM( [table 1]column 1) , Filter([table1]column 2 = 4100),Filter([table1]column 2 = 4110) ),
       IF(max([Label[label])="IT-dept.", Calculate ( SUM( [table 1]column 1) , Filter([table1]column 2 = 1410), Filter([table1]column 2 = 2500)),BKANK()))

 

And if question still not solved ,could you pls share your sample data for [table1] and [table 1],and expect output result?

 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

 

View solution in original post

3 REPLIES 3
v-luwang-msft
Community Support
Community Support

Hi @Robin9700 ,

In my opinion,you need to create a new label table :

vluwangmsft_0-1645153861500.png

 

And if you want to create a new column,test like below:

newcolumn=if([Label[label]="Labour costs",
               Calculate ( SUM( [table 1]column 1 , [table1]column 2 = 4000),
          IF([Label[label]="Ads/marketing",
Calculate ( SUM( [table 1]column 1) , Filter([table1]column 2 = 4100),Filter([table1]column 2 = 4110) ),
       IF([Label[label]="IT-dept.", Calculate ( SUM( [table 1]column 1) , Filter([table1]column 2 = 1410), Filter([table1]column 2 = 2500)),BKANK()))

And if you want to create a new measure,test like below:

newcolumn=if(max([Label[label])="Labour costs",
               Calculate ( SUM( [table 1]column 1 , [table1]column 2 = 4000),
          IF(max([Label[label])="Ads/marketing",
Calculate ( SUM( [table 1]column 1) , Filter([table1]column 2 = 4100),Filter([table1]column 2 = 4110) ),
       IF(max([Label[label])="IT-dept.", Calculate ( SUM( [table 1]column 1) , Filter([table1]column 2 = 1410), Filter([table1]column 2 = 2500)),BKANK()))

 

And if question still not solved ,could you pls share your sample data for [table1] and [table 1],and expect output result?

 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

 

DataInsights
Super User
Super User

@Robin9700,

 

You can achieve this with a disconnected table (no relationships). Use "Enter data" to manually input the data. The Index column is used for sorting in a visual. Example:

 

DataInsights_0-1644933920808.png

 

Create measures for each label (9 measures). Then, create a SWITCH measure that uses the appropriate measure.

 

Label Measure =
SWITCH (
    SELECTEDVALUE ( Labels[Label] ),
    "Labour costs", [Labour costs],
    "Ads/marketing", [Ads/marketing]
)

 

In a matrix visual (for example), use Labels[Label] as rows, and [Label Measure] as values.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




TheoC
Super User
Super User

Hi @Robin9700 

 

If you create a measure for each row in your post, you can then title the measures exactly what you have in your column 1. Drag the measures into a Matrix visual (into the Value field), then turn on the option "Show on Rows".

 

https://powerbidocs.com/2020/10/09/show-values-on-rows-for-matrix-visual/ 

 

This will give you an output exactly as you require. 

 

I hope this is what you're searching for.

 

All the best.

Theo

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.