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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ryan_b_fiting
Post Patron
Post Patron

Calculated Column removing filter context

Hello - 

 

I am trying to create a calculated column that will provide me the SUM of the cost based on a specific date value for the row in my table.

 

I have 4 main tables:

Wireless_Numbers, Date_Table, Overview of Lines, Monthly_Costs with the below sample data:

 

Wireless Numbers:

idWirelessnumber
1xxxxxxx
2xxxxxxx
3xxxxxxx
4xxxxxxx
5xxxxxxx
6xxxxxxx
7xxxxxxx

 

Overview of Lines (Cost is the column i want to calculate):

numberidwirelessnumberBill Cycle DateActivation DateBenchmark Cycle DateCost
1xxxxxxx1/1/20221/1/20191/1/2022                                   32.00
2xxxxxxx1/1/20221/2/20191/1/2022                                   31.00
3xxxxxxx1/1/20221/3/20191/1/2022                                   33.00
4xxxxxxx1/1/20221/4/20191/1/2022                                   33.00
5xxxxxxx1/1/20221/5/20191/1/2022                                   23.00
6xxxxxxx1/1/20221/6/20191/1/2022                                   26.00
1xxxxxxx2/1/20221/1/20191/1/2022                                   32.00
2xxxxxxx2/1/20221/2/20191/1/2022                                   31.00
3xxxxxxx2/1/20221/3/20191/1/2022                                   33.00
4xxxxxxx2/1/20221/4/20191/1/2022                                   33.00
5xxxxxxx2/1/20221/5/20191/1/2022                                   23.00
6xxxxxxx2/1/20221/6/20191/1/2022                                   26.00
7xxxxxxx2/1/20222/12/20222/1/2022                                   32.00
1xxxxxxx3/1/20221/1/20191/1/2022                                   32.00
2xxxxxxx3/1/20221/2/20191/1/2022                                   31.00
3xxxxxxx3/1/20221/3/20191/1/2022                                   33.00
4xxxxxxx3/1/20221/4/20191/1/2022                                   33.00
5xxxxxxx3/1/20221/5/20191/1/2022                                   23.00
6xxxxxxx3/1/20221/6/20191/1/2022                                   26.00
7xxxxxxx3/1/20222/12/20222/1/2022                                   32.00

 

Monthly_Cost

numberidwirelessnumberBill Cycle DateCost CategoryCost
1xxxxxxx1/1/2022Data Usage17
2xxxxxxx1/1/2022Data Usage17
3xxxxxxx1/1/2022Data Usage16
4xxxxxxx1/1/2022Data Usage16
5xxxxxxx1/1/2022Data Usage13
6xxxxxxx1/1/2022Data Usage14
1xxxxxxx2/1/2022Data Usage12
2xxxxxxx2/1/2022Data Usage15
3xxxxxxx2/1/2022Data Usage16
4xxxxxxx2/1/2022Data Usage18
5xxxxxxx2/1/2022Data Usage16
6xxxxxxx2/1/2022Data Usage18
7xxxxxxx2/1/2022Data Usage20
1xxxxxxx3/1/2022Data Usage17
2xxxxxxx3/1/2022Data Usage15
3xxxxxxx3/1/2022Data Usage18
4xxxxxxx3/1/2022Data Usage12
5xxxxxxx3/1/2022Data Usage14
6xxxxxxx3/1/2022Data Usage14
7xxxxxxx3/1/2022Data Usage11
1xxxxxxx1/1/2022Fees and Taxes15
2xxxxxxx1/1/2022Fees and Taxes14
3xxxxxxx1/1/2022Fees and Taxes17
4xxxxxxx1/1/2022Fees and Taxes17
5xxxxxxx1/1/2022Fees and Taxes10
6xxxxxxx1/1/2022Fees and Taxes12
1xxxxxxx2/1/2022Fees and Taxes11
2xxxxxxx2/1/2022Fees and Taxes10
3xxxxxxx2/1/2022Fees and Taxes10
4xxxxxxx2/1/2022Fees and Taxes12
5xxxxxxx2/1/2022Fees and Taxes13
6xxxxxxx2/1/2022Fees and Taxes15
7xxxxxxx2/1/2022Fees and Taxes12
1xxxxxxx3/1/2022Fees and Taxes20
2xxxxxxx3/1/2022Fees and Taxes13
3xxxxxxx3/1/2022Fees and Taxes20
4xxxxxxx3/1/2022Fees and Taxes15
5xxxxxxx3/1/2022Fees and Taxes20
6xxxxxxx3/1/2022Fees and Taxes15
7xxxxxxx3/1/2022Fees and Taxes15

 

Date Table is standard date dimensional table that is joined to the fact tables on Bill Cycle Date.

 

What I am looking to do is calculate the COST from the Monthly_cost table for the Benchmark Date associated with each Wireless number.  So even if we are looking at March 2022 reporting, I want to see what our cost was for January 2022 for the wirelessid 1, 2 etc.  

 

We need to compare our benchmark costs, versus our go forward monthly costs to see the monthly savings we are generating for each wireless number.

 

Is there a way to essentially create this SUMIF excel statement in Power BI:

SUMIFS(Cost, wireless number (Monthly Cost) = Wireless Number (row in Overview of Lines) AND Bill Cycle Date (Monthly Cost) = Benchmark Date (Overview of lines).

 

I have been trying to figure out this solution with no luck so any help would be great!

Thanks
Ryan

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

Hi @ryan_b_fiting ,

Please refer to my pbix file to see if it helps you.

Create relationships between tables.

vpollymsft_0-1675909269272.png

Create a column.

Column =
CALCULATE (
    SUM ( 'monthly cost'[Cost] ),
    FILTER (
        'monthly cost',
        'monthly cost'[wirelessnumber] = EARLIER ( 'Overview of Lines'[wirelessnumber] )
            && 'monthly cost'[Bill Cycle Date]
                = EARLIER ( 'Overview of Lines'[Benchmark Cycle Date] )
    )
)

Or a measure.

Measure_RE =
CALCULATE (
    SUM ( 'monthly cost'[Cost] ),
    FILTER (
        ALL ( 'monthly cost' ),
        'monthly cost'[wirelessnumber]
            = SELECTEDVALUE ( 'Overview of Lines'[wirelessnumber] )
            && 'monthly cost'[Bill Cycle Date]
                = SELECTEDVALUE ( 'Overview of Lines'[Benchmark Cycle Date] )
    )
)

vpollymsft_1-1675909343777.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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
v-rongtiep-msft
Community Support
Community Support

Hi @ryan_b_fiting ,

Please refer to my pbix file to see if it helps you.

Create relationships between tables.

vpollymsft_0-1675909269272.png

Create a column.

Column =
CALCULATE (
    SUM ( 'monthly cost'[Cost] ),
    FILTER (
        'monthly cost',
        'monthly cost'[wirelessnumber] = EARLIER ( 'Overview of Lines'[wirelessnumber] )
            && 'monthly cost'[Bill Cycle Date]
                = EARLIER ( 'Overview of Lines'[Benchmark Cycle Date] )
    )
)

Or a measure.

Measure_RE =
CALCULATE (
    SUM ( 'monthly cost'[Cost] ),
    FILTER (
        ALL ( 'monthly cost' ),
        'monthly cost'[wirelessnumber]
            = SELECTEDVALUE ( 'Overview of Lines'[wirelessnumber] )
            && 'monthly cost'[Bill Cycle Date]
                = SELECTEDVALUE ( 'Overview of Lines'[Benchmark Cycle Date] )
    )
)

vpollymsft_1-1675909343777.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

 

Thanks @v-rongtiep-msft the column worked as expected.  The measure did not give me the expected output, but I am using the calculated column and it is working for me!

 

Thanks again for the assistance. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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