Forum Discussion

forbi's avatar
forbi
Frequent Visitor
3 years ago
Solved

dax percentage calculation

I have two tables :   ID type days 1 C 5 2 C 10 3 N 7 4 C 15   Product Deadline A 10 B 15   I want to calculate by a measure : Divide count rows...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi forbi ,

    Please try below steps:

    1. below is my test table 

    Table1:

    Table2:

    2. create a measure with below dax formula

    Measure =
    VAR pt =
        SELECTEDVALUE ( Table2[Product] )
    VAR dl =
        CALCULATE ( MAX ( Table2[Deadline] ), Table2[Product] = pt )
    VAR tmp1 =
        FILTER ( ALL ( Table1 ), Table1[Type] = pt && Table1[Days] <= dl )
    VAR tmp2 =
        FILTER ( ALL ( Table1 ), Table1[Type] = pt )
    RETURN
        DIVIDE ( COUNTROWS ( tmp1 ), COUNTROWS ( tmp2 ) )
    

    3. add some visual like below

    Please refer the attached .pbix file.

     

    Best regards,
    Community Support Team_Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.