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
TobiasV
New Member

Dynamic calculations over several tables

Hallo everyone,

 

i have a tricky problem which i cannot solve on my own and i hope you can help me. 🙂

I have three Tables (two of them are connected with a Key):

 

Table 1:

KeyValue_before
120
230
340

 

Table 2:

KeyValue_after
120
240
30

 

Table3:

i
0,05
0,1

 

I would like to visualize the following value:

Delta = MAX(0, Value_After - Value_Before * (1+i) )

and the user has the option to set the value of i to 0,05 or 0,1 with a slicer.

 

For example, if i want to display the overall sum of Delta (with slicer for i = 0,1) it should show the following value: 

MAX(0, 20-22) + MAX(0, 40-33) + MAX(0, 0-44) = 7

 

Is there a way to do this with a meassure? 

Thank you for your help!

 

Best wishes

Tobias

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

Hi @TobiasV ,

 

We assume you have a one-to-one relationship between Table 1 and Table 2.

 

D1.jpg

 

Then we can create a measure to meet your requirement.

 

Measure = 
VAR _select_i =
    SELECTEDVALUE ( 'Slicer table'[i], 0 )
RETURN
    SUMX (
        VALUES ( 'Table 1'[Key] ),
        MAX (
            0,
            CALCULATE ( SUM ( 'Table 2'[Value_after] ) )
                - CALCULATE ( SUM ( 'Table 1'[Value_before] ) ) * ( 1 + _select_i )
        )
    )

 

D2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

View solution in original post

2 REPLIES 2
v-zhenbw-msft
Community Support
Community Support

Hi @TobiasV ,

 

We assume you have a one-to-one relationship between Table 1 and Table 2.

 

D1.jpg

 

Then we can create a measure to meet your requirement.

 

Measure = 
VAR _select_i =
    SELECTEDVALUE ( 'Slicer table'[i], 0 )
RETURN
    SUMX (
        VALUES ( 'Table 1'[Key] ),
        MAX (
            0,
            CALCULATE ( SUM ( 'Table 2'[Value_after] ) )
                - CALCULATE ( SUM ( 'Table 1'[Value_before] ) ) * ( 1 + _select_i )
        )
    )

 

D2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

parry2k
Super User
Super User

@TobiasV how table 1 and 2 are related? Is it 1:1 relationship or 1 to many ?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.