Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hey Experts,
I need help with dax.
I have two columns one is SALE DATE and one is ORDER DATE. I need one column or measure according below condition,
Ever order date has multiple sale date.
My sale date always should be last thursday of month. so whatever order date is there whichever coming sale date is "current" for me and otherones are "Next" for me.
example:
Order date | Sale date | Exp(REQUIRED MEASURE) |
16/03/2022 | |||31/03/2022(last thursday of march) | |||Current |
16/03/2022 | |||28/04/2022(last thursday of april) | |||Next |
22/04/2022 | |||28/04/2022(last thursday of april) | |||Current |
22/04/2022 | |||26/05/2022(last thursday of may) | |||Next |
22/04/2022 | |||30/06/2022(last thursday of jun) | |||Next |
29/04/2022 | |||26/05/2022(last thursday of may) | |||Current |
29/04/2022 | |||30/06/2022(last thursday of jun) | |||Next |
I hope uou clear withrequirment. I want EXP as measure.
Solved! Go to Solution.
Hi, @Anonymous ;
Try it.
result =
VAR _min =
CALCULATE ( MIN ( Data[Sale date] ),FILTER(ALLSELECTED('Data'),[Order date]=MAX([Order date])))
RETURN
IF (
MAX( Data[Sale date] ) = _min,
"Current",
"Next")
The final output is shown below:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Anonymous ;
Try it.
result =
VAR _min =
CALCULATE ( MIN ( Data[Sale date] ),FILTER(ALLSELECTED('Data'),[Order date]=MAX([Order date])))
RETURN
IF (
MAX( Data[Sale date] ) = _min,
"Current",
"Next")
The final output is shown below:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello @Anonymous
First make a Date dimension table (Date = CALENDARAUTO()) and make following relationship between 'Order Date' and 'Date':
After that use following measure:
Please accept it as a solution if it matches your requirement🙂
Hi @Anonymous
You can try this calculated column
Distribution Column: =
VAR CurrentSaleDate = Data[exp]
VAR CurrentOrderDateTable =
CALCULATETABLE ( Sheet1, ALLEXCEPT ( Sheet1, Sheet1[Date] ) )
VAR NumberOfSales =
COUNTROWS ( CurrentOrderDateTable )
VAR FirstSaleDate =
MINX ( CurrentOrderDateTable, Sheet1[exp] )
VAR Result =
IF (
NumberOfSales = 1,
"Current",
IF ( CurrentSaleDate = FirstSaleDate, "Current", "Next" )
)
RETURN
Result
Measure working fine after adding filter value. But calculated column giving not proper result.
Hi @Anonymous
Would you please double check the code you're using as it works in sample file https://www.dropbox.com/t/yGBAowmIe1PHgg7b
@Anonymous
Also I believe that the solution provide by @Jihwan_Kim should work with no issues. Is there any chance that we are missing something here?
Hi,
Please check the below picture and the attached pbix file.
Expected result measure: =
VAR currentorderdate =
MAX ( Data[Order date] )
VAR commingsalesdate =
CALCULATE ( MIN ( Data[Sale date] ), ALLEXCEPT ( Data, Data[Order date] ) )
VAR result =
IF (
SELECTEDVALUE ( Data[Order date] ) = currentorderdate
&& SELECTEDVALUE ( Data[Sale date] ) = commingsalesdate,
"Current",
"Next"
)
RETURN
IF ( HASONEVALUE ( Data[Order date] ), result )
Please share your sample.
I think the sample that is described in your question is different than what you show in the reply.
Sorry sir. Its my mistake. I applied some filter on page if i mention that filter in mymeasure its working fine. but my question is if i add more filter in future it automatically make my measure wrong. any solution for that sir>
Not Working in my case.
@amitchandak @tamerj1 @Whitewater100 @AlexisOlson @Jihwan_Kim
Great guys please help