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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
siva_powerbi
Helper IV
Helper IV

use columns from another table DAX

I have two tables one table has the real time data with dimensions and measures, and other tables is manual table with values of one of the dimension.

 

Example data (Apologize for few records):

 

Dimension     amount

Hard Disk        400

Mouse             100

Keyboard         200

 

My report requirement is to add the rows at end of these items as "Total Sales", "Net Sales" for each store

 

To achieve this I have create a manual table with data

 

Store   Dimension

1           Hard Disk

1           Mouse

1           KeyBoard

1           Total Sales

1            Net Sales

 

Now I have use manual table in report and want to extract the values from real time table I should be able to add formulas for "Total Sales" and "Net Sales" and display data for remaining attributes as it is, linked both tables on store id. Tried many ways but without success

 

Out of ideas on how to start with this requirement, I can display data if everything comes from single table but in this scenario I am unable to start at first point.

 

Any help is greatly appretiated.

 

Thanks

Siva

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @siva_powerbi  ,

According to your description, I create this data:

Table1:

v-yangliu-msft_0-1613608603354.png

Table2:

v-yangliu-msft_1-1613608603356.png

Table3:

v-yangliu-msft_2-1613608603357.png

Here are the steps you can follow:

1. Create calculated column.

Column =
var _grouptotals=CALCULATE(SUM('Table1'[amount]),FILTER('Table1','Table1'[Date]<=TODAY()&&'Table1'[Store]=EARLIER('Table2'[Store])&&'Table1'[Dimension]=EARLIER('Table2'[Dimension])))
var _totals=CALCULATE(SUM('Table1'[amount]),FILTER('Table1','Table1'[Date]<=TODAY()&&'Table1'[Store]=EARLIER('Table2'[Store])))
var _counthd=CALCULATE(COUNT('Table1'[Dimension]),FILTER(ALL('Table1'),'Table1'[Dimension]=MIN('Table2'[Dimension])))
var _allpurchase=SUMX('Table3','Table3'[Purchase price]*_counthd)
return
SWITCH(
    TRUE(),
    'Table2'[Dimension]="Total Sales",_totals,
    'Table2'[Dimension]="Net Sales",_totals-_allpurchase,
    _grouptotals)

2. Result

Table1 has not been updated yet, the data of Table2:

v-yangliu-msft_3-1613608603359.png

After Table1 is updated:

v-yangliu-msft_4-1613608603361.png

Data in Table2 table after update:

v-yangliu-msft_5-1613608603362.png

You can downloaded PBIX file from here.

If my answer is not what you want,can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @siva_powerbi  ,

According to your description, I create this data:

Table1:

v-yangliu-msft_0-1613608603354.png

Table2:

v-yangliu-msft_1-1613608603356.png

Table3:

v-yangliu-msft_2-1613608603357.png

Here are the steps you can follow:

1. Create calculated column.

Column =
var _grouptotals=CALCULATE(SUM('Table1'[amount]),FILTER('Table1','Table1'[Date]<=TODAY()&&'Table1'[Store]=EARLIER('Table2'[Store])&&'Table1'[Dimension]=EARLIER('Table2'[Dimension])))
var _totals=CALCULATE(SUM('Table1'[amount]),FILTER('Table1','Table1'[Date]<=TODAY()&&'Table1'[Store]=EARLIER('Table2'[Store])))
var _counthd=CALCULATE(COUNT('Table1'[Dimension]),FILTER(ALL('Table1'),'Table1'[Dimension]=MIN('Table2'[Dimension])))
var _allpurchase=SUMX('Table3','Table3'[Purchase price]*_counthd)
return
SWITCH(
    TRUE(),
    'Table2'[Dimension]="Total Sales",_totals,
    'Table2'[Dimension]="Net Sales",_totals-_allpurchase,
    _grouptotals)

2. Result

Table1 has not been updated yet, the data of Table2:

v-yangliu-msft_3-1613608603359.png

After Table1 is updated:

v-yangliu-msft_4-1613608603361.png

Data in Table2 table after update:

v-yangliu-msft_5-1613608603362.png

You can downloaded PBIX file from here.

If my answer is not what you want,can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@siva_powerbi , If you want to add to tables, that would static will not change with filter. If you append only UI difficult to get that.

 

Which one you want?

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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