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
Leroynz
Frequent Visitor

Sum from another non related (can't link) table

Hi,

I have two tables: Table A has column "Booking #" and column "Method", Table A Booking # has multiple entries but each entry will only have one Method e.g email, web. Table B has column "Booking ID" and column "Lost Savings". Table B Booking ID contains mulitple entries of differing amounts with the same ID. In both tables the Booking # and Booking ID represent the same thing however I can't link the tables as when I do it comes up with mulitple entries error and won't link.

 

I want to be able to show the Lost Savings per method but the values all show as the total amount. Any help would be appreciated.

 

Row LabelsSum of Lost SavingsGrand Total$51,322.64

 

Method 
(blank)$51,322.64
After Hours$51,322.64
E mail$51,322.64
Fax$51,322.64
Method$51,322.64
Mixed Web$51,322.64
Telephone$51,322.64
Web$51,322.64
Web Request$51,322.64

Row LabelsSum of Lost SavingsGrand Total$51,322.64

2 ACCEPTED SOLUTIONS
v-shex-msft
Community Support
Community Support

Hi @Leroynz,

 

For tables which not contains relationship, you need to manually get current item as condition to filter with row contents, otherwise they will return static value.

 

Sample measure:

Lost SavingsGrand =
VAR Booklist =
    CALCULATETABLE ( VALUES ( TableA[Booking #] ), VALUES ( TableA[Method] ) )
RETURN
    CALCULATE (
        SUM ( TableB[Lost Savings] ),
        FILTER ( ALL ( TableB ), [Booking ID] IN Booklist )
    )

Then use method column and above measure to create table visual.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

Anonymous
Not applicable

Try this 

Lost SavingsGrand=
VAR Booklist =
CALCULATETABLE (VALUES('Raw FCM data'[booking_id]),VALUES('Raw FCM data'[Method]))
RETURN
CALCULATE( SUM('Raw Lost Savings Data'[Lost Savings]), FILTER(ALL('Raw FCM data'), 'Raw FCM data'[booking_id] IN Booklist))

your formula seems to have extrac ending brackets.

View solution in original post

5 REPLIES 5
v-shex-msft
Community Support
Community Support

Hi @Leroynz,

 

For tables which not contains relationship, you need to manually get current item as condition to filter with row contents, otherwise they will return static value.

 

Sample measure:

Lost SavingsGrand =
VAR Booklist =
    CALCULATETABLE ( VALUES ( TableA[Booking #] ), VALUES ( TableA[Method] ) )
RETURN
    CALCULATE (
        SUM ( TableB[Lost Savings] ),
        FILTER ( ALL ( TableB ), [Booking ID] IN Booklist )
    )

Then use method column and above measure to create table visual.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

 

Hi Xiaoxim,

Thanks for your reply.

 

I've tried loading the formula but it is not accepting it. i've included a screenshot of what the error message says.

 

Error.PNGFormula.PNG

Anonymous
Not applicable

Hi @Leroynz : 

By looking at your screenshot it seems to be a missing some syntax, so I suggest to use the DAX formatter to get the DAX formula formatted properly. I copied the same formula and it seems to be working.

Give it a try and just paste the formatter on in the Power BI and see it it works. 

 

 

https://www.daxformatter.com/


@Anonymous wrote:

Hi @Leroynz : 

By looking at your screenshot it seems to be a missing some syntax, so I suggest to use the DAX formatter to get the DAX formula formatted properly. I copied the same formula and it seems to be working.

Give it a try and just paste the formatter on in the Power BI and see it it works. 

 

 

https://www.daxformatter.com/


Thanks Jayant,

I've entered the code into the daxformatter site as follows: It works in the site however when I copy it intp Power Query it errors saying the syntax for 'IN' is incorrect. (In Power Query when entering the measure formula the "IN Booklist" has a squiggly red line underneath it

Lost SavingsGrand=
VAR Booklist =
CALCULATETABLE (
VALUES('Raw FCM data'[booking_id]),
VALUES('Raw FCM data'[Method])
)
RETURN
CALCULATE(
SUM('Raw Lost Savings Data'[Lost Savings]),
FILTER(ALL('Raw FCM data'), 'Raw FCM data'[booking_id] IN Booklist)

)
))
Anonymous
Not applicable

Try this 

Lost SavingsGrand=
VAR Booklist =
CALCULATETABLE (VALUES('Raw FCM data'[booking_id]),VALUES('Raw FCM data'[Method]))
RETURN
CALCULATE( SUM('Raw Lost Savings Data'[Lost Savings]), FILTER(ALL('Raw FCM data'), 'Raw FCM data'[booking_id] IN Booklist))

your formula seems to have extrac ending brackets.

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.