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

DAX measurement for two dates in same table and using filter

I have one table and I have a condition to calculate 

To calculate order by US $ with:
  1. delivered condition is Yes
  2. any order date equal or greater than the selected date ( 7th of Jule)
  3. any shipped date equal or greater than the selected date ( 7th of Jule)

 

To calculate Shipped by US $ with:
  1. delivered condition is Yes
  2. any shipped date equal or greater than the selected date ( 7th of Jule)

Note: I built a calendar table where the start date is equal to order date and the last date is the maximum shipped date

alialsayer_0-1625488890380.png

please if anyone could help 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @alialsayer 

if 

vxiaotang_0-1625724963961.png

use measure like bellow:

measure1 = 
VAR _seldate=SELECTEDVALUE('calendar'[Date])
RETURN
CALCULATE(Sum('Table'[US]), FILTER('Table',('Table'[Order Date] >=_seldate || 'Table'[Shipped Date] >=_seldate ) && 'Table'[Deliver] = "Yes"))

if

vxiaotang_1-1625725018315.png

then

measure1 = 
VAR _seldate=SELECTEDVALUE('calendar'[Date])
RETURN
CALCULATE(Sum('Table'[US]), FILTER('Table',('Table'[Order Date] >=_seldate && 'Table'[Shipped Date] >=_seldate ) && 'Table'[Deliver] = "Yes"))

-

measure2 = 
VAR _seldate=SELECTEDVALUE('calendar'[Date])
RETURN
CALCULATE(Sum('Table'[US]), FILTER('Table','Table'[Shipped Date] >=_seldate  && 'Table'[Deliver] = "Yes"))

-

result:

vxiaotang_2-1625725364719.gif

 

 

Best Regards,

Community Support Team _ Tang

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

View solution in original post

4 REPLIES 4
v-xiaotang
Community Support
Community Support

Hi @alialsayer 

if 

vxiaotang_0-1625724963961.png

use measure like bellow:

measure1 = 
VAR _seldate=SELECTEDVALUE('calendar'[Date])
RETURN
CALCULATE(Sum('Table'[US]), FILTER('Table',('Table'[Order Date] >=_seldate || 'Table'[Shipped Date] >=_seldate ) && 'Table'[Deliver] = "Yes"))

if

vxiaotang_1-1625725018315.png

then

measure1 = 
VAR _seldate=SELECTEDVALUE('calendar'[Date])
RETURN
CALCULATE(Sum('Table'[US]), FILTER('Table',('Table'[Order Date] >=_seldate && 'Table'[Shipped Date] >=_seldate ) && 'Table'[Deliver] = "Yes"))

-

measure2 = 
VAR _seldate=SELECTEDVALUE('calendar'[Date])
RETURN
CALCULATE(Sum('Table'[US]), FILTER('Table','Table'[Shipped Date] >=_seldate  && 'Table'[Deliver] = "Yes"))

-

result:

vxiaotang_2-1625725364719.gif

 

 

Best Regards,

Community Support Team _ Tang

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

Thanks, it works with me, I really appreciate your help and your attached example make this easy to understand 🌹

amitchandak
Super User
Super User

@alialsayer , with help from independent date table

 


measure 1=
VAR minDate = MINX( allselected('Calendar') , 'Calendar'[Date] )
VAR maxDate = MAXX(allselected('Calendar') , 'Calendar'[Date] )
RETURN
CALCULATE(Sum(Table[US$]), filter( Table,Table[Order Date] >=_min && Table[Shipped Date] >=_max && Tbale[delivered] = "Yes"))



measure 2 =
VAR minDate = MINX( allselected('Calendar') , 'Calendar'[Date] )
VAR maxDate = MAXX(allselected('Calendar') , 'Calendar'[Date] )
RETURN
CALCULATE(Sum(Table[US$]), filter( Table, Table[Shipped Date] >=_max && Table[delivered] = "Yes"))

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

Thank you, I try these VAR measures but it doesn't work for me. It gives me wrong numbers 

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