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
carlovsky
Helper II
Helper II

Percentage from the grand total by each seller | DAX

Hi all,

I'm looking for a DAX measure that gives me 1 if the vendor cancelled more than 5% of the orders from their own grand total

Can you please help? I have no idea on how to do it

 

SAMPLE Table:

Sample 

 

Raw Data:

VendorCod_OrderVendor Cancelled
10523320
117232111
1163214551
107123110
10423561
12556320
11498670
10854210

 

Sample Expected output:

Aggregation per seller with a FLAG = 1 if the Vendor cancelled more than 5% of his own total orders

 

VendorVendor cancellations > 5 %
1051
1000
1070

 

SAMPLE Table:

Sample 

 

 

Thank you

Diego

1 ACCEPTED SOLUTION
Jos_Woolley
Solution Sage
Solution Sage

Hi,

 

MyFlag :=
VAR MyThreshold = 0.05
VAR Orders =
    COUNTROWS( Data )
VAR Cancelled =
    CALCULATE(
        COUNTROWS( Data ),
        Data[Vendor Cancelled] = 1
    )
VAR ProportionCancelled =
    DIVIDE(
        Cancelled,
        Orders
    )
VAR ToFlag = 0 + ( ProportionCancelled > MyThreshold )
RETURN
    ToFlag

 

Regards

View solution in original post

2 REPLIES 2
Jos_Woolley
Solution Sage
Solution Sage

Hi,

 

MyFlag :=
VAR MyThreshold = 0.05
VAR Orders =
    COUNTROWS( Data )
VAR Cancelled =
    CALCULATE(
        COUNTROWS( Data ),
        Data[Vendor Cancelled] = 1
    )
VAR ProportionCancelled =
    DIVIDE(
        Cancelled,
        Orders
    )
VAR ToFlag = 0 + ( ProportionCancelled > MyThreshold )
RETURN
    ToFlag

 

Regards

tamerj1
Super User
Super User

Hi @carlovsky 

you can use 

DIVIDE ( SUM, CALCULATE (SUM, ALSELECTED(Table[Vendor]))

then compare with IF >= 0.5

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