Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago
Solved

DAX DATESBETWEEN

I have a list of campaigns, each record has a Start and Finish date associated with it. 

 

I want to be able to get the MINX of Start, the MAXX of Finish, and populate another table with all the dates inbetween the lower and upper range. I am trying to use DATESBETWEEN but am stumbling on the syntax. E.g.

 

Measure = DATESBETWEEN(DateDimension[DateSK],
	MINX(Campaign_Report,Campaign_Report[Start]),
	MAXX(Campaign_Report,Campaign_Report[Finish]))

 

which doesn't return anything (no error either).... Could this be because I am trying to run this in a new table which already has one column populated in it:

 

Table = all(Campaign_Report[UID_CAMPAIGN]
	)

Can anyone give me a nudge in the right direction? Thanks

 

 

 

 

  • Anonymous You should use New Table option under Modelling tab and then use DAX code you've got. From syntax it seems like you're trying to create a measure using DATESBETWEEN which returns table and so it is not working.

  • Anonymous's avatar
    Anonymous
    9 years ago

    Thanks for your replies - manged to do it with:

     

    Table = CALENDAR( minx(Campaign_Report,Campaign_Report[Start]), maxx(Campaign_Report,Campaign_Report[Finish] ))

4 Replies

  • It seems to me that you are confused with your requirements. Can you please clearly explain what do you mean by 

     

    "populate another table with all the dates inbetween the lower and upper range."  Posting Sample data and expected output would be highly appreciated.

  • ankitpatira's avatar
    ankitpatira
    Community Champion

    Anonymous You should use New Table option under Modelling tab and then use DAX code you've got. From syntax it seems like you're trying to create a measure using DATESBETWEEN which returns table and so it is not working.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for your replies - manged to do it with:

       

      Table = CALENDAR( minx(Campaign_Report,Campaign_Report[Start]), maxx(Campaign_Report,Campaign_Report[Finish] ))
      • BhaveshPatel's avatar
        BhaveshPatel
        Super User

        If you think the problem is solved, Can you please mark it as a solution. So the thread can be closed.