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
Lily36876
Helper I
Helper I

A cross table complex condition

Hi Experts!

 

I have two tables, one containing the monthly incentive amount for each store counter, and the other containing the sales personnel for each store counter and whether they have reached the monthly target. I want to calculate the incentive amount for each store counter to be evenly distributed only among the sales personnel who have reached their monthly targets.

 

Lily36876_0-1711416587543.png

 

1 ACCEPTED SOLUTION

Hi @Lily36876 

The solution @ryan_mayu  provided is excellent, I want to offer some more information for you to refer to, the sample data is the same as you provided.

You can create the following measure.

MEASURE =
VAR a =
    CALCULATE (
        MAX ( 'Monthly incentive amount'[Incentive] ),
        'Monthly incentive amount'[ShopNo]
            = MAX ( 'Sales personnel store counter'[ShopNo] ),
        'Monthly incentive amount'[YearMonth]
            = MAX ( 'Sales personnel store counter'[YearMonth] )
    )
VAR b =
    CALCULATE (
        COUNTROWS ( 'Sales personnel store counter' ),
        ALLSELECTED ( 'Sales personnel store counter' ),
        'Sales personnel store counter'[ShopNo]
            IN VALUES ( 'Sales personnel store counter'[ShopNo] ),
        'Sales personnel store counter'[YearMonth]
            IN VALUES ( 'Sales personnel store counter'[YearMonth] ),
        'Sales personnel store counter'[Achieve] = "YES"
    )
RETURN
    IF (
        MAX ( 'Sales personnel store counter'[Achieve] ) <> BLANK (),
        DIVIDE ( a, b )
    )

Output

vxinruzhumsft_0-1711677664081.png

Best Regards!

Yolo Zhu

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

9 REPLIES 9
ryan_mayu
Super User
Super User

how to calculate the incentive column?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Identify sales in the store who have achieved the performance targets, and then evenly distribute the incentive.

why there is no value for 078?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




078 didn't reach the target in 2024/01 ,so can't got the incentive~

 

Thanks

you can do this in PQ

11.PNG

 

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Yes It's what I want!!!

But the pivot table I provide is after summerize in Dax

Hi @Lily36876 

The solution @ryan_mayu  provided is excellent, I want to offer some more information for you to refer to, the sample data is the same as you provided.

You can create the following measure.

MEASURE =
VAR a =
    CALCULATE (
        MAX ( 'Monthly incentive amount'[Incentive] ),
        'Monthly incentive amount'[ShopNo]
            = MAX ( 'Sales personnel store counter'[ShopNo] ),
        'Monthly incentive amount'[YearMonth]
            = MAX ( 'Sales personnel store counter'[YearMonth] )
    )
VAR b =
    CALCULATE (
        COUNTROWS ( 'Sales personnel store counter' ),
        ALLSELECTED ( 'Sales personnel store counter' ),
        'Sales personnel store counter'[ShopNo]
            IN VALUES ( 'Sales personnel store counter'[ShopNo] ),
        'Sales personnel store counter'[YearMonth]
            IN VALUES ( 'Sales personnel store counter'[YearMonth] ),
        'Sales personnel store counter'[Achieve] = "YES"
    )
RETURN
    IF (
        MAX ( 'Sales personnel store counter'[Achieve] ) <> BLANK (),
        DIVIDE ( a, b )
    )

Output

vxinruzhumsft_0-1711677664081.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Thanks for your amazing and useful and right solution!!!!

you can group by data in PQ.

https://learn.microsoft.com/en-us/power-query/group-by?wt.mc_id=DP-MVP-5004616

 

or pls provide the raw data





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.