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
forbi
Frequent Visitor

dax percentage calculation

I have two tables :

 

IDtypedays
1C5
2C10
3N7
4C

15

 

ProductDeadline
A10
B15

 

I want to calculate by a measure :

Divide
count rows where type = C and days <= deadline ,
count rows where type = C

1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @forbi ,

Please try below steps:

1. below is my test table 

Table1:

vbinbinyumsft_0-1673851067834.png

Table2:

vbinbinyumsft_1-1673851083047.png

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

vbinbinyumsft_2-1673851239504.png

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.

View solution in original post

2 REPLIES 2
v-binbinyu-msft
Community Support
Community Support

Hi @forbi ,

Please try below steps:

1. below is my test table 

Table1:

vbinbinyumsft_0-1673851067834.png

Table2:

vbinbinyumsft_1-1673851083047.png

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

vbinbinyumsft_2-1673851239504.png

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.

amitchandak
Super User
Super User

@forbi , what is the join column between two table?

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