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
aglpr
Advocate II
Advocate II

Divide Sum of value group by the unique count of the group

Hello all,

 

Apologize for messy/confusing title.

 

I'm fairly new to Power BI and DAX thing, so I have a question about dividing a sum of the number from a group with the count number of the group itself.

 

I have 2 tables. Transactions Table (Trx Table) and a table from Google Analytics.

 

I have this sessions value of the source/medium from the GA table

 

DateSourceMediumSource/MediunSessions
12 03 2022googlecpcgooglecpc6963
12 03 2022facebookcpcfacebookcpc856

 

Which is 6963 for googlecpc sessions

 

and I want to divide it with the count transactions number of that group in the Transactions Table

 

DateSource/MediumStatus
12 03 2022googlecpcSuccess
12 03 2022googlecpcFail
12 03 2022googlecpcSuccess
12 03 2022googlecpcFail
12 03 2022googlecpcSuccess

 

which in that table there are 5 transactions from googlecpc.

 

So, the calculations for the date 6 March will be 6963 divided by 5.

 

Anyone know how to create the DAX for this? I already tried to do research but still found no appropriate formula

 

Thank you!

 

1 ACCEPTED SOLUTION
tackytechtom
Super User
Super User

Hi @aglpr ,

 

How about this:

tomfox_0-1647165377025.png

 

 

I used this formular:

TomsDivideMeasure = 
DIVIDE ( 
    CALCULATE ( 
        SUM ( TableGA[Sessions] ) 
    ),
    CALCULATE (
        COUNTROWS ( TableTrx )
    )
) 

Does this get you closer to a solution? 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

2 REPLIES 2
tackytechtom
Super User
Super User

Hi @aglpr ,

 

How about this:

tomfox_0-1647165377025.png

 

 

I used this formular:

TomsDivideMeasure = 
DIVIDE ( 
    CALCULATE ( 
        SUM ( TableGA[Sessions] ) 
    ),
    CALCULATE (
        COUNTROWS ( TableTrx )
    )
) 

Does this get you closer to a solution? 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Hello Tom,

 

Thank you so much for the formula. Actually I mistype the expected calculations. It should be 5 divided by 6963, not 6963 divided by 5. But I change the order of the formula provided by you and it works! Keep forgotting how advanced the CALCULATION is

 

Thank you so much!

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.

Top Solution Authors