Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

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
Anonymous
Not applicable

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
Anonymous
Not applicable

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?

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.