cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

Frequent Visitor

Calculation using different tables with no relationship

Table A: Outbound

 Date_id Org_id OutboundUnits 1 80 500.00 2 80 600.00 3 80 700.00 1 86 100.00 2 86 200.00 3 86 300.00

Table B: Inbound

 Date_id Org_id Vendor_id InboundUnits 1 80 1 50.00 1 80 2 60.00 2 80 1 70.00 2 80 2 10.00 3 80 1 20.00 3 80 2 30.00 1 86 1 50.00 1 86 2 60.00 2 86 1 70.00 2 86 2 10.00 3 86 1 20.00 3 86 2 30.00

Table C: GoalUPH (Goal Units per Hour)

 Date_id Org_id GoalUPH 1 80 20.00 2 80 20.00 3 80 20.00 1 86 25.00 2 86 25.00 3 86 25.00

My data model has the above setup of tables A, B and C (amongst many other tables). Unfortunately, there is no active/inactive relationship between these A, B, C tables (since my PowerBI desktop doesn't allow for many-to-many relationships). I am trying to achieve the following formula:

HoursNeeded = (OutboundUnits + InboundUnits) / GoalUPH --> for each combination of Date_id and Org_id.

So, for example, for Date_id = 1 and Org_id = 80, the calculation would (mathematically) go like:

HoursNeeded = (500.00 + (50.00 + 60.00)) / 20.00 = 30.5

I'd appreciate any help in creating the above calculation. Thanks!

2 ACCEPTED SOLUTIONS
Super User

@RavitPBI , Create two/three common dimension table date, org, and vendor. Accompany them with boards and then use it.

Refer to this video how two create one when they have one -https://www.youtube.com/watch?v=Bkf35Roman8

Provide your feedback and tips for new videos
Dax Series Tutorial Vs SQL Direct Query PBI Tips

Community Support

Hi, @RavitPBI

It’s my pleasure to answer for you.

According to your description, I think you can create two slicers(column in table C) and a measure to calculate the desired result.

Like this:

``````HoursNeeded =
VAR dateid =
SELECTEDVALUE ( GoalUPH[Date_id] )
VAR orgid =
SELECTEDVALUE ( GoalUPH[Org_id] )
VAR sumunits =
SUMX (
FILTER ( ALL ( Outbound ), [Date_id] = dateid && [Org_id] = orgid ),
[OutboundUnits]
)
+ SUMX (
FILTER ( ALL ( Inbound ), [Date_id] = dateid && [Org_id] = orgid ),
[InboundUnits]
)
RETURN
IF (
ISFILTERED ( GoalUPH[Date_id] ) && ISFILTERED ( GoalUPH[Org_id] ),
DIVIDE ( sumunits, SELECTEDVALUE ( GoalUPH[GoalUPH] ) ),
0
)``````

Best Regards

Janey Guo

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

4 REPLIES 4
Community Support

Hi, @RavitPBI

It’s my pleasure to answer for you.

According to your description, I think you can create two slicers(column in table C) and a measure to calculate the desired result.

Like this:

``````HoursNeeded =
VAR dateid =
SELECTEDVALUE ( GoalUPH[Date_id] )
VAR orgid =
SELECTEDVALUE ( GoalUPH[Org_id] )
VAR sumunits =
SUMX (
FILTER ( ALL ( Outbound ), [Date_id] = dateid && [Org_id] = orgid ),
[OutboundUnits]
)
+ SUMX (
FILTER ( ALL ( Inbound ), [Date_id] = dateid && [Org_id] = orgid ),
[InboundUnits]
)
RETURN
IF (
ISFILTERED ( GoalUPH[Date_id] ) && ISFILTERED ( GoalUPH[Org_id] ),
DIVIDE ( sumunits, SELECTEDVALUE ( GoalUPH[GoalUPH] ) ),
0
)``````

Best Regards

Janey Guo

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

Frequent Visitor

Thanks for sharing the solution. While it seems this calculation would work with your recommendation, however, usage of slicer is not an option for me. This calculation should be performed behind the scenes without the use of any end-user interaction. Appreciate the help!

Super User

@RavitPBI , Create two/three common dimension table date, org, and vendor. Accompany them with boards and then use it.

Refer to this video how two create one when they have one -https://www.youtube.com/watch?v=Bkf35Roman8

Provide your feedback and tips for new videos
Dax Series Tutorial Vs SQL Direct Query PBI Tips

Frequent Visitor

Hi @amitchandak,

Thanks for providing the right direction. The video gave some ideas to build upon my own solution using bridge tables. Appreciate the help a lot! 🙂

Announcements

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.