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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
amsrivastavaa
Helper III
Helper III

Reference Table from DAX

Hi Guys!!

 

My requirment is to create one Reference table using DAX in such a way that if there is any change in base table it will also get reflected in Reference table as well.

 

Lets say, I have one Filter F-1 and One Table visual Table-1, let say User saelected any value in F-1 and data got filtered in Table-1, i need to create Table-2 that refrenced Table-1, that is as soon as F-1 filtered the Table-1, Table-2 also get filtered and always have same set of data as Table-1 has.

 

Please suggest how can  we do this via DAX

 

Thanks

Amit Srivastava

14 REPLIES 14
mangaus1111
Solution Sage
Solution Sage

Hi @amsrivastavaa ,

try this maybe it works

 

Total_Amount = CALCULATE(SUM('Facts17'[Amount]),ALLSELECTED(Facts17))
 
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @mangaus1111 

 

Thats giving me sum of all the records, i need sum based on Type and year for whatever data left after applying filter.

 

Thanks

Amit

Greg_Deckler
Community Champion
Community Champion

@amsrivastavaa You cannot. DAX calculated columns and tables are not dynamic, they are calculated at the time of refresh.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler ,

 

Can we have something like this using DAX as detailed below.

 

Let say I have table Transaction as shown below

 

ProjectTypeYearAmountTotal_Amount
P-1A2017100160
P-2A201750160
P-3A201710160
P-1A20182075
P-2A20185575
P-1A201975250
P-2A201985250
P-3A201990250

 

Project, Type, Year & Total_Amount is coming from Source however for Total_Amount i have created using below DAX

Total_Amount = CALCULATE(SUM('Transaction'[Amount]),ALLEXCEPT('Transaction','Transaction'[Type],'Transaction'[Year]))

 

This works well when we have complete set of data but when user selects say Project=P-1 in slicers , then amount of all other Project P-2, P-3 still added in Total_Amount.

 

I want, when user selects say P-1, then it will only sum amount for P-1 project for Total_Amount measure, similarly, if User Selects P-2 and P-1 both, Total_Amount must be sum of all the amounts of Project P-1 and P-2.

 

Based on above table.

If user select Project= P-1, Year=2017 then  Total_Amount = 100

If user select Project= P-1 and P-2, Year=2017 then  Total_Amount = 100+50 = 150.

If user select Project= P-1 ,P-2 and P-3, Year=2017 then  Total_Amount = 100+50 +10= 160

 

Can we define measure (tot_amount) in such a way that it will work on data which is available after filteration.

 

Thanks

Amit 

@amsrivastavaa That should be possible:

Total_Amount = CALCULATE(SUM('Transaction'[Amount]),ALLEXCEPT('Transaction','Transaction'[Type],'Transaction'[Year],'Transaction'[Project]))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler ,

 

Below is the layout of the data 

amsrivastavaa_1-1666439420183.png

Tot_Amount = 

 

Total_Amount = CALCULATE(SUM('Transaction'[Amount]),ALLEXCEPT('Transaction','Transaction'[Type],'Transaction'[Year])

 

Total_Amount = 

 

Total_Amount = CALCULATE(SUM('Transaction'[Amount]),ALLEXCEPT('Transaction','Transaction'[Type],'Transaction'[Year],'Transaction'[Project]))

 

Filter available : Project

First Instance : When user have selected all the Project, then Total sum for Credit across all the project for Year 2017 is 1210 i.e. Tot_Amount value.

Second Instance : When user have selected Project as P-1 and P-2 only, as shown below

amsrivastavaa_2-1666439689036.png

Then, Total Sum of Amount for Credit across all the project for Year 2017 must be 1000 +100=1100.

But  none of the above DAX gave me correct result.

 

I need DAX which will calculate Total Amount based on what data available after filteration

 

Please suggest!!

 

Thanks

Amit 

 

@amsrivastavaa See attached PBIX file below signature. The measure seems to work for both of your scenarios. Returns 1210 if just Year = 2017 and 1,100 if P1 and P2 and Year = 2017. You have to use a measure, you cannot use a column.

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler ,

 

Reason, why I want to have it as a column is

- I want to filter transaction table based on this column.

- Whatever data left after applying filter, I have to create Matrix visual for that data.

 

So, if I will create measure for this,  I will not be able to filter the data and subsequently not able to create Matrix visual.

 

ANy thought or work around??

 

Thanks

Amit

@amsrivastavaa You can filter a visual using a measure. I can't exactly picture what you are trying to do here in terms of your matrix. Can you provide a mock-up? 

 

The only way to do this using calculated columns is you would have to create a column for every possible combination of what users might select/filter and that's just not a feasible solution. I'm pretty certain there is a way to get what you want using measures, but I need to understand what you are really trying to accomplish because it is not clear to me.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler 

 

I have placed the PBI on onedrive, please find on the below URL

 

https://1drv.ms/u/s!Ahtm7otFIxr8cX5JDN5SEc0Vajw?e=xREfsH

 

As a brief, below are the requirement detail

 

Requirement

User wants to see Matrix report only for those project where AMOUNT/Total AMOUNT is less than 25% (if user selected <25% in Range slicer).

 

Other details are available in PBI.

 

Thanks

Amit

 

@amsrivastavaa See attached PBIX below signature. Wish we would have started with the real requirement. You basically need a complex selector. 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler ,

Many Many Thanks for the same, its incredible.

 

I have gone through the PBI and it looks good as of now with only exception.

 

Range slicer works well when I am selecting any value in the Range slicer and subsequent records dispaly in the table, however when I didn't selected anything in the slicer, its not showing any records in the table, on the contrary, if nothing selected in Power BI slicers then means all the values of slicers is part of the result set.

 

Could you please help me on the same as well, i.e.when nothing selected in Range filter, it will not filter anything and complete data will get dispalyed.

 

Thanks

Amit Srivastava

@amsrivastavaa Sure, use this version:

Selector 2 = 
    VAR __Amount = SUM('Amit'[Amount])
    VAR __TotalAmount = [Total_Amount 2]
    VAR __Percent = DIVIDE(__Amount, __TotalAmount)
    VAR __Range = SELECTEDVALUE('Range-Amit'[Range])
    VAR __Ranges = COUNTROWS(DISTINCT('Range-Amit'[Range]))
    VAR __AllRanges = COUNTROWS(DISTINCT(ALL('Range-Amit'[Range])))
RETURN
    SWITCH(TRUE(),
        __Ranges = __AllRanges,1,
        __Range = "<25%" && __Percent < .25,1,
        __Range = "25-50%" && __Percent >= .25 && __Percent < .5,1,
        __Range = "50-75%" && __Percent >= .5 && __Percent < .75,1,
        __Range = "75-100%" && __Percent >= .75 && __Percent < 1,1,
        0
    )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler ,

 

I have updated the SELECTOR 2 with code provided, for most of the records, it works well, i have found just one exception which is detailed below

 

amsrivastavaa_0-1666465680868.png

Just to explain, I have selected Type=Credit, Year=2017 and Range =50-75, then it gives me records with Amount as 1000, however 100*(1000/1210 )=82.6 which must be part of 75-100%, so please suggests!!

 

Another requirement I just realised is : Lets say in Tabular View 2 after applying Slicers, I have got record for Project=P-1, then I need to accumulated all the records that belongs to P-1, i.e. all the records of Type = Debit and Type=Credit for Year 2017 (as P-1 belongs to 2017 in this case) and then have to create Matrix on top of that data.

 

To elaborate further, let say, in Tabular View-2, I have got two records after filteration, one for (Project=P-1 and Year=2017) and another (Project=P-2 and Year=2018) then first i need to accumulate all the data (Type=Debit or Type=CREDIT) for (Project=P-1 and Year=2017) and another (Project=P-2 and Year=2018) and then create Matrix visualization.

 

Please suggest!!

 

Thanks

Amit 

 

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors