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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Helpful_Fun4848
Helper III
Helper III

How to get total amount based on dates criteria

Hi all,

I have a column for Expected Delivery and another column showing $ amount. I would like to calculate the sum of the $ amount when Expected Delivery is between zero (today) to 30 days after, 30 days - 60 days, etc.  What's the best way of doing this? Thx all!!

1 ACCEPTED SOLUTION

Problem solved: I created custom column with True or False if Expect Delivery is within 0-30 days

 

0-30 Column

= if [ExpectDelivery] >= DateTime.LocalNow() and [ExpectDelivery] <= Date.AddDays(DateTime.LocalNow(),30) then "True" else "False"

 

and then, I created a measure to Sum the $amount if the answer is True.  

 

CALCULATE(
SUM(Table[AmtOrdered]),
Table[0-30] = "True"
)

 

View solution in original post

12 REPLIES 12
v-luwang-msft
Community Support
Community Support

Hi @Helpful_Fun4848 ,

Has your problem been solved, if so, please consider Accept a correct reply as the solution or share your own solution to help others find it.

Best Regards
Lucien

Problem solved: I created custom column with True or False if Expect Delivery is within 0-30 days

 

0-30 Column

= if [ExpectDelivery] >= DateTime.LocalNow() and [ExpectDelivery] <= Date.AddDays(DateTime.LocalNow(),30) then "True" else "False"

 

and then, I created a measure to Sum the $amount if the answer is True.  

 

CALCULATE(
SUM(Table[AmtOrdered]),
Table[0-30] = "True"
)

 

v-luwang-msft
Community Support
Community Support

Hi  @Helpful_Fun4848 ,

In my sample ,it with the same value .But my sampe not with the column supplier.

vluwangmsft_0-1635902751370.png

And could you pls share your pbix file through a public link?Remember to remove confidential data.

 

 

Best Regards

Lucien

v-luwang-msft
Community Support
Community Support

Hi @Helpful_Fun4848 ,

Test like the below:

Base data:

vluwangmsft_0-1635491082253.png

Use the following dax to create measure:

 

 

30DAY = CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),'Table'[Expected Delivery]>=NOW()&&'Table'[Expected Delivery]<=NOW()+30))
30to60 = CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),'Table'[Expected Delivery]>=NOW()+30&&'Table'[Expected Delivery]<=NOW()+60))

 

 

Then create visual:

vluwangmsft_1-1635491256141.png

 

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


Best Regards

Lucien

@v-luwang-msft 

 

It works! However, I have another question. There is another column for Suppliers and I tried to create Clustered bar chart to show Amount from largest to smallest per Supplier for each 0-30 days, 30-60 days, etc. 

When I select the measure and the supplier onto the chart, the chart is showing incorrect result. For example, the total amount for 0-30 days = $1.2M, the chart shows the same amount of $1.2M for every Suppliers.

 

If I create Table, it'll show the result like the table on your post above where every Suppliers have $1.2M in the next 30 days. 

Much appreciate it if you could tell me the solution!

Hi,

Share some data and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Helpful_Fun4848 ,

Try the following measure ,a little adjust:

30DAY =
CALCULATE (
    SUM ( 'Table'[amount] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Expected Delivery] >= NOW ()
            && 'Table'[Expected Delivery]
                <= NOW () + 30
            && 'Table'[Supplier] = MAX ( 'Table'[Supplier] )
    )
)
30to60 =
CALCULATE (
    SUM ( 'Table'[amount] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Expected Delivery]
            >= NOW () + 30
            && 'Table'[Expected Delivery]
                <= NOW () + 60
            && 'Table'[Supplier] = MAX ( 'Table'[Supplier] )
    )
)

 

 

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


Best Regards

Lucien

@v-luwang-msft 

 

There is one issue:

 

If I create table, the total is showing the last amount only. 

 

Helpful_Fun4848_0-1635788052722.png

 

Once again, thank you in advance!!

Hi @Helpful_Fun4848 ,

Try to base on the measure,create a new measure:

Measure 2 = SUMX('Table','Table'[30DAY])

vluwangmsft_0-1635816379503.png

 

 


Best Regards

Lucien

@v-luwang-msft 

 

I still have some issues:

 

I created the SUMX measure and if I use it on the table: 

Helpful_Fun4848_0-1635872426566.png

If I use the SUMX measure on the card, the total showing different result:

Helpful_Fun4848_1-1635872562743.png

 

Why table total different than card total?

 

Much thx!!

 

 

amitchandak
Super User
Super User

@Helpful_Fun4848 , How want this diff, based on today?

 

like

new column =

var _1=  datediff([Delivery Date], today(),day)

Switch( True() ,

_1< 0, "  Past due",

_1<=30 , "  0 - 30 days",

_1<=60 , "  30 - 60 days",

"More than 60 day"  // add others as per need

)

 

 

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

@amitchandak 

 

What exactly is var _1? I'm assuming it's Variable? When I tried to create custom column, Variable.Value is the only variable available. 

 

Also, I do not see Datediff as one of the formula available.

 

Thanks!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

Top Solution Authors
Top Kudoed Authors