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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
jamuka
Helper IV
Helper IV

Divide between two tables

Hello,

I want to divide my total sales amount in Sales Table to total visitor number based on location in Visitors Table.

Tables have inactive relationship, based on store location (there are two location) between them.

When I tried to use simple divide, it divides all visitors instead of location level. 

 

 

Sales table

DateStore LocationStore NoProduct CategoryProduct IDSales Amount
1.05.2020AA-1Cat-A250
1.05.2020BB-1Cat-B375
1.05.2020AA-2Cat-A150
1.05.2020BB-2Cat-C475
2.05.2020AA-1Cat-A250
2.05.2020BB-1Cat-B575
2.05.2020AA-2Cat-B350
2.05.2020BB-2Cat-B775

 

Visitors table

DateStore LocationVisitor
1.05.2020A1.500
1.05.2020B2.000
2.05.2020A1.000
2.05.2020B1.750

 

in excel my expected result looks like this

 

Store LocationProduct CategoryTotal SalesSales Per Visitor
ACat-A1500,06
ACat-B500,02
BCat-B2250,06
BCat-C750,02

 

My Data model is

Data Model.png

 

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @jamuka 

Since the relationship is inactive, place the fields shown from the Sales table in a table visual and create a measure:

NumVisitors =
CALCULATE (
    SUM ( VistorsT[Visitor] ),
    FILTER (
        ALL ( VistorsT ),
        VisitorsT[Store Location] = SELECTEDVALUE ( SalesT[Store Location] )
            && VisitorsT[Date] = SELECTEDVALUE ( SalesT[Date] )
    )
)

 This will give you the number of visitors in that location and day. Yo can use that to calculate the quotient as required

Please mark the question solved when done and consider giving kudos if posts are helpful.

 Cheers 

SU18_powerbi_badge

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@jamuka , you should join both tables with Store and then you can analyze data for the store , there you will be able to see both sum of sales and visitor

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

Hello @amitchandak,

 

When I join Visitor Table to Store Table and add visitor column to my visual it shows same value (total visitor) for each row instead of location's sum of visitor.

Greg_Deckler
Community Champion
Community Champion

You either need a better data model or USERELATIONSHIPS.

 

If you made that relationship uni-directional from Sales to Visitors, it wouldn't be inactive.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hello @Greg_Deckler  thank you for your reply.

I made the relationship from sales to visitors but couldn't make it active due to ambiguity between Date and Visitors Tables.

I tried to use USERELATIONSHIPS but couldn't finda relevant sample.

 

also I realized my question has missing information therefore I updated it, sorry for inconvenience.

AlB
Community Champion
Community Champion

Hi @jamuka 

Since the relationship is inactive, place the fields shown from the Sales table in a table visual and create a measure:

NumVisitors =
CALCULATE (
    SUM ( VistorsT[Visitor] ),
    FILTER (
        ALL ( VistorsT ),
        VisitorsT[Store Location] = SELECTEDVALUE ( SalesT[Store Location] )
            && VisitorsT[Date] = SELECTEDVALUE ( SalesT[Date] )
    )
)

 This will give you the number of visitors in that location and day. Yo can use that to calculate the quotient as required

Please mark the question solved when done and consider giving kudos if posts are helpful.

 Cheers 

SU18_powerbi_badge

Hello @AlB ,

 

thanks for your help. Measure is working but I realized my question has missing information, I updated it.

I want to show values based on location and product category level and filter it with a slicer based on year month (e.g Jan '20).

So I tweaked my Visitor Table and add year month column, then tweaked your formula too.

Although it shows correct values on product category and shows subtotal on location level it didn't show on total values on Total level. I guess I have to change my Sales Table, add visitor amount to it then tried to find another way to calculate with correct numbers.

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Solution Authors