Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Division result categorization with data from 2 different tables.

Hello,
I have the following tables:


F_NEWBUSINESS

 

DELIVERY_DATEACCT_IDMAIN_DEALER_CODE
31/01/20231A
31/01/20232A
31/01/20233B
28/02/20234C
28/02/20235A
28/02/20236B


F_DEALERSALES

 

DELIVERY_DATEIDMAIN_DEALER_CODERETAIL_SOLD
31/01/20231A3
31/01/20232A5
31/01/20233B2
28/02/20234C1
28/02/20235A0
28/02/20236C4

 

I am trying to categorize the result of the division:
count of newbusiness/sum of retail sold, by main_dealer_code

 

To calculate the division I have this metric:

 

Dealer Fin Pen =

 

DIVIDE(
    CALCULATE(
        COUNT(F_newbusiness[acct_id]),
        FILTER(
            F_NEWBUSINESS,
            F_NEWBUSINESS[MAIN_DEALER_CODE]
        )    
    ),
    CALCULATE(
        SUM(F_dealersales[retail_sold]),
        FILTER(
            F_DEALERSALES,
            F_DEALERSALES[MAIN_DEALER_CODE]
        )
    )
)
I need to show in a Line Chart visual the amount of main dealers that fall under each category with each category being one line in the chart and with the categories being the following:
- dealers FP <20%  when Dealer Fin Pen < 0.2
- dealers FP 20-40% when Dealer Fin Pen > 0.2 && Dealer Fin Pen <= 0.4
- dealers FP >40% when Dealer Fin Pen > 0.4
This last part is where I am having troubles, I am not able to count the amount of main dealers that falls under each category.
Any tips or ideas on how can i do this?
 
Thanks in advance!
  • Hi, Anonymous 

     

    try this one. 


    Count Dealers FP <20% =
    CALCULATE(
    COUNTROWS(F_NEWBUSINESS),
    FILTER(
    ALL(F_NEWBUSINESS),
    [Dealer Fin Pen] < 0.2
    )
    )

    Count Dealers FP 20-40% =
    CALCULATE(
    COUNTROWS(F_NEWBUSINESS),
    FILTER(
    ALL(F_NEWBUSINESS),
    [Dealer Fin Pen] >= 0.2 && [Dealer Fin Pen] <= 0.4
    )
    )

    Count Dealers FP >40% =
    CALCULATE(
    COUNTROWS(F_NEWBUSINESS),
    FILTER(
    ALL(F_NEWBUSINESS),
    [Dealer Fin Pen] > 0.4
    )
    )

2 Replies

  • rubayatyasmin's avatar
    rubayatyasmin
    Icon for Community Champion rankCommunity Champion

    Hi, Anonymous 

     

    try this one. 


    Count Dealers FP <20% =
    CALCULATE(
    COUNTROWS(F_NEWBUSINESS),
    FILTER(
    ALL(F_NEWBUSINESS),
    [Dealer Fin Pen] < 0.2
    )
    )

    Count Dealers FP 20-40% =
    CALCULATE(
    COUNTROWS(F_NEWBUSINESS),
    FILTER(
    ALL(F_NEWBUSINESS),
    [Dealer Fin Pen] >= 0.2 && [Dealer Fin Pen] <= 0.4
    )
    )

    Count Dealers FP >40% =
    CALCULATE(
    COUNTROWS(F_NEWBUSINESS),
    FILTER(
    ALL(F_NEWBUSINESS),
    [Dealer Fin Pen] > 0.4
    )
    )

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello rubayatyasmin ,

       

      Seems promising, but thanks to this I have found out, that I have some "." as main_dealer_codes in the data which is giving me problems to calculate the metric due to text to true or false evaluation raising an error, as soon as I solve this, I will let you know if it worked or not.

      Thanks a lot and happy new year! 🙂