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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Inserting a column in to Date Table

Hi,

I need to put this logic in to a custom column or any other logical column as a seperate column in to my Date table,

 

Custom_Date=
VAR minDate =
CALCULATE ( MIN ( DateTable[Date] ) )
VAR maxDate =
CALCULATE ( MAX ( DateTable[Date] ) )
RETURN
IF (
MAX ( DateTable[Date] ) >= minDate
&& MAX ( DateTable[Date] ) <= maxDate,
minDate & " " & maxDate
)
 
Can anyone help me on this?
 
Thanks
1 ACCEPTED SOLUTION

@Anonymous 

It was supposed to be used in the Data Model using DAX. 
Add in the model date table and check if you get the results.

If you want to add it in Power Query, add below code as a new custom column

=Date.ToText(Date.StartOfYear([Date]),"dd-MMM-yy") &" --- "& Date.ToText( [Date],"dd-MMM-yy")




________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

7 REPLIES 7
Fowmy
Super User
Super User

@Anonymous 

I am not sure about the usage of this column in a visual but this custom column should give you what you expect:

Custom_Date = 

 VAR _START = MIN(DateTable[Date])
 VAR _CURRENT = [Date]

RETURN
 _START & "  " & _CURRENT 

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

@Fowmy 

I used your formula in custom column.But its shows an error.

 

Mishelle_0-1598857687033.png

 

Hi , @Anonymous 

@Fowmy 's solution could work.

If yes, please accept his reply as solution, so that other community members will easily find the solution when they get the same issue.For now, there is no content of description in the thread. If you still need help, please feel free to ask.

 

Best Regards,
Community Support Team _ Eason

@Anonymous 

It was supposed to be used in the Data Model using DAX. 
Add in the model date table and check if you get the results.

If you want to add it in Power Query, add below code as a new custom column

=Date.ToText(Date.StartOfYear([Date]),"dd-MMM-yy") &" --- "& Date.ToText( [Date],"dd-MMM-yy")




________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

amitchandak
Super User
Super User

@Anonymous , what calculation you are looking for. Min and max you are taking in the column calculations are the min-max of the calendar. so you will end up getting

_min & " _ " _max

 

Appended min and max dates. What you are looking for?

 

 

Anonymous
Not applicable

@amitchandak 

Im want to get min and max date from the date calendar. I can get the dates using a measure.But i cant put a measure as a category in waterfall chart.I need to use this column as x axis in my water fall chart.So in the chart i want to show only first date of the year and todate.

Above i put my measure loguc and simply i need to use this logic in to a column.I tried calculated column but it didnt work.so i need to use this measure in query editor and use as a custom or conditional column.

 

Thanks

@Anonymous , if you want to show YTD, use datesytd with calendar and slicer

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

 

If you min date of the year you can use

startofyear([Date])  // make sure start of year date is there in calendar else it will take min available date

https://docs.microsoft.com/en-us/dax/startofyear-function-dax

 

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.