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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Rngomoa
Frequent Visitor

Using dateadd with Max

Am trying to create a Dax to select cases within the defined date period as follows. However, when remove the curdate2, am able to view some results but when i use curdate2, there is not result. I however, need to select cases whose visit is above -28 days of the selected date.

 

tx_curr2 =
VAR curdate = MAX(CalenderDate[dates])
VAR curdate2=DATEADD(CalenderDate[dates],-28,DAY)

RETURN
COUNTX(
FILTER(
ADDCOLUMNS(
SUMMARIZE(Greencard,Greencard[patient_id],Greencard[mflcode],"tx_curr2", CALCULATE(COUNT(Greencard[patient_id]), Greencard[visit_date] <= curdate && Greencard[visit_date] <= Greencard[ExitDate1] && Greencard[visit_date] > curdate2)
),
"tx_curr3", IF([tx_curr2] > 0, 1, 0)
),
[tx_curr3] > 0
),Greencard[patient_id])

 

1 ACCEPTED SOLUTION
andhiii079845
Solution Sage
Solution Sage

The probem is that you use a column in this DAX expression:
You need to use something like SELECTEDVALUE(CalenderDate[dates]) or VALUES or MAXX i think.
 curdate2=DATEADD(CalenderDate[dates],-28,DAY)





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

Proud to be a Super User!




View solution in original post

4 REPLIES 4
andhiii079845
Solution Sage
Solution Sage

I play a little bit with your problem. Very interesting, this work, i hope:

--> 

tx_curr2 =
VAR curdate = MAX(CalenderDate[dates])
VAR curdate2=SELECTEDVALUE(CalenderDate[dates])-28 

RETURN
COUNTX(
FILTER(
ADDCOLUMNS(
SUMMARIZE(Greencard,Greencard[patient_id],Greencard[mflcode],"tx_curr2"CALCULATE(COUNT(Greencard[patient_id]), Greencard[visit_date] <= curdate && Greencard[visit_date] <= Greencard[ExitDate1] && Greencard[visit_date] > curdate2)
),
"tx_curr3"IF([tx_curr2] > 010)
),
[tx_curr3] > 0
),Greencard[patient_id])




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

Proud to be a Super User!




andhiii079845
Solution Sage
Solution Sage

Can you please show, how you use the the measure? In a matrix? With which columns? 





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

Proud to be a Super User!




andhiii079845
Solution Sage
Solution Sage

The probem is that you use a column in this DAX expression:
You need to use something like SELECTEDVALUE(CalenderDate[dates]) or VALUES or MAXX i think.
 curdate2=DATEADD(CalenderDate[dates],-28,DAY)





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

Proud to be a Super User!




Thanks for your response. I have tried your suggestion but it's not working.

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.