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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
DaneHowarth
New Member

Filtering a result based on another column

Hi all

 

I am looking for some help to figure out the DAX required to filter a column by another column.  I have included some data below to illustrate the problem. 

 

In this example there are 3 companies (Alpha, Bravo, and Charlie). Alpha and Bravo are both to be compared against Bravo's sales (Reference Company). What i am trying to figure is how to calculate Reference Company Sales in the output.

I though the DAX might go as follows but it doenst work as A_Table[Company] doesnt return all rows, only the current row.

 

 

Reference Company Sales = CALCULATE(SUM[Sales],filter(A_Table, A_Table[Company]=[Reference Company]))

 

 

 

 

The example is below:

DaneHowarth_0-1660287769788.png

 

 

DaneHowarth_1-1660286276367.png

 

 

Thanks in advance for any help you are able to provide.

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @DaneHowarth 
Here is a sample file with the solution https://www.dropbox.com/t/T2GfvtNkOp8FqBl4

Reference Company Sales = 
CALCULATE ( 
    SUM ( A_Table[Sales] ),
    REMOVEFILTERS ( A_Table ),
    TREATAS ( VALUES ( A_Table[Reference Company] ), A_Table[Company] )
)

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @DaneHowarth 
I just noticed that my original solution deliveres correct results but wrong total. Here is the solution with the correct total https://www.dropbox.com/t/z9kBn81LzoPEG7Ex

Reference Company Sales = 
SUMX (
    SUMMARIZE ( A_Table, A_Table[Company], A_Table[Reference Company] ),
    CALCULATE ( 
        CALCULATE ( 
            SUM ( A_Table[Sales] ),
            REMOVEFILTERS(),
            TREATAS ( VALUES ( A_Table[Reference Company] ), A_Table[Company])
        )
    )
)
tamerj1
Super User
Super User

Hi @DaneHowarth 
Here is a sample file with the solution https://www.dropbox.com/t/T2GfvtNkOp8FqBl4

Reference Company Sales = 
CALCULATE ( 
    SUM ( A_Table[Sales] ),
    REMOVEFILTERS ( A_Table ),
    TREATAS ( VALUES ( A_Table[Reference Company] ), A_Table[Company] )
)
amitchandak
Super User
Super User

@DaneHowarth , Create a measure like

Reference Company Sales = CALCULATE(SUM(Table[Sales]),filter(allselected(A_Table), A_Table[Company]= max(Table[Reference Company])))

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

Awesome, thanks so much @amitchandak 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.