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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Junaid11
Helper V
Helper V

Divide Latest week value with sum of Sales

Hello,

I want to divide the latest AR value with sum of Salesand then multiply it with number of Days. But when I am dividing it with total sales value it is automatically dividing it with all week sales. I am attaching my data as well as outcome I want to have. Kindly have a look at it. A help would be highly appreciated.

Thank you

 

Weeknum Sales  AR Days in week
1 $    594,935.76 $      343,466,7677
2 $    423,051.96 $        67,955,89414
3 $    378,467.79 $              568,56921
4 $    379,376.90 $           8,990,95528
5 $    459,192.74 $        17,413,34135
6 $ 1,065,006.10 $        25,835,72742
7 $    642,491.90 $           5,201,53349

sddfvvvv.PNG

Outcome I need is for week 7 it would be ($ 5,201,533/$ 3,942,523.15) * 49 = 64.533

64.533 would be the outcome for week 7.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Junaid11 ,

You can create a measure as below to get it, please find the details in the attachment.

Measure = 
VAR _selweek =
    SELECTEDVALUE ( 'Table'[Weeknum] )
VAR _sales =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Weeknum] <= _selweek )
    )
VAR _ar =
    CALCULATE (
        SUM ( 'Table'[AR] ),
        FILTER ( 'Table', 'Table'[Weeknum] = _selweek )
    )
VAR _days =
    CALCULATE (
        MAX ( 'Table'[Days in week] ),
        FILTER ( 'Table', 'Table'[Weeknum] = _selweek )
    )
RETURN
    DIVIDE ( _ar, _sales ) * _days

yingyinr_0-1648802516966.png

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Junaid11 ,

You can create a measure as below to get it, please find the details in the attachment.

Measure = 
VAR _selweek =
    SELECTEDVALUE ( 'Table'[Weeknum] )
VAR _sales =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Weeknum] <= _selweek )
    )
VAR _ar =
    CALCULATE (
        SUM ( 'Table'[AR] ),
        FILTER ( 'Table', 'Table'[Weeknum] = _selweek )
    )
VAR _days =
    CALCULATE (
        MAX ( 'Table'[Days in week] ),
        FILTER ( 'Table', 'Table'[Weeknum] = _selweek )
    )
RETURN
    DIVIDE ( _ar, _sales ) * _days

yingyinr_0-1648802516966.png

Best Regards

PijushRoy
Super User
Super User

Hi @Junaid11 

Please try this

Measure = DIVIDE(SUM('Table'[ AR ]),CALCULATE(SUM('Table'[ Sales ]),ALL('Table '[Weeknum])))*SELECTEDVALUE('Table'[Days in week])


If solve your requirement, please mark this answer as SOLUTION
If this comment helps you, please LIKE this comment/Kudos



Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 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.