Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Dax Formula for Division

Hi,

 

I have Total customers =500 and Customer_Type are ordinary(200) and  Membership(300). i want to write a formula for sales ration which is

 

Total Customer (500)/ only memebership(300)=60% is my sales ration

 

As my customer type how i can define in formula like Sales ration= (Total Customers/ value where customer_type="membership)

2 Replies

  • Try like


    divide(countx(filter(customer,customer[Type]="Membership"),customer[ID])
    ,calculate(count(customer[ID]),all(customer)))

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Sample data would make this quesiton much more clear. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

     

    That being said, you might try something like:

    Sales Ratio =
      VAR __TotalCustomers = COUNTROWS(ALL('Customers'))
      VAR __MemberCustomers = COUNTROWS(FILTER(ALL('Customers'),[Customer_Type]="membership"))
    RETURN
      DIVIDE(__MemberCustomers,__TotalCustomers,0)