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

How to use the max() value of a DateTime Field

Hello!

Im trying to extract the second input of a DateTime box to create a new table which has only the time dates of that month time input (from start until the month end).

Captura.JPG

 

Andrés_1-1610549521515.png

Andrés_2-1610549649682.png

 

 

I tried this code but i got the december dates from 2024 (my input is january 2021)

 

day1 = CALCULATETABLE(Calendario,DATESBETWEEN(Calendario[Fecha].[Date], DATE(YEAR(max('Calendario'[Fecha].[date])),MONTH(max('Calendario'[Fecha].[date])),1),DATE(YEAR(max('Calendario'[Fecha].[date])),MONTH(max('Calendario'[Fecha].[date])),31)))

Andrés_3-1610549783578.png

Andrés_4-1610549892087.png

 

Thank you all!

1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @Anonymous 

 

According to your description, if you don't want to change the value in values (written with measure), it is very difficult to only change the x-axis dynamically. I have a workaound here.

You can create a measure,then use it in filter pane and use date hierarchy in x axis. Note that the slicer uses a date table.

Measure = 
VAR month =
    MONTH ( MAX ( 'Table'[Date] ) )
VAR year =
    YEAR ( MAX ( 'Table'[Date] ) )
VAR last =
    EOMONTH ( MAX ( 'Table'[Date] ), 0 )
VAR first =
    DATE ( year, month, 1 )
RETURN
    IF (
        SELECTEDVALUE ( Table1[date] ) >= first
            && SELECTEDVALUE ( Table1[date] ) <= last,
        1,
        0
    )

1.png

Here is my sample .pbix file.Hope it helps.

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

View solution in original post

13 REPLIES 13
parry2k
Super User
Super User

@Anonymous 2nd table is getting data from excel file, click transform data and you will see excel as a data source.

 

parry2k_0-1610997532077.png

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous so what is your question? The expression in the first table is used to create a date table and 2nd table is just a regular data table with a date column in it, like any other table in the model. Not sure what is your question or what is not clear?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous that is just a date column in the table, not sure what is your question?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hii, 

the first table has a formula:

Andrés_0-1610997222740.png

The second doesnt

Andrés_1-1610997291345.png

 

v-janeyg-msft
Community Support
Community Support

Hi, @Anonymous 

 

According to your description, if you don't want to change the value in values (written with measure), it is very difficult to only change the x-axis dynamically. I have a workaound here.

You can create a measure,then use it in filter pane and use date hierarchy in x axis. Note that the slicer uses a date table.

Measure = 
VAR month =
    MONTH ( MAX ( 'Table'[Date] ) )
VAR year =
    YEAR ( MAX ( 'Table'[Date] ) )
VAR last =
    EOMONTH ( MAX ( 'Table'[Date] ), 0 )
VAR first =
    DATE ( year, month, 1 )
RETURN
    IF (
        SELECTEDVALUE ( Table1[date] ) >= first
            && SELECTEDVALUE ( Table1[date] ) <= last,
        1,
        0
    )

1.png

Here is my sample .pbix file.Hope it helps.

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

Anonymous
Not applicable

Hello @v-janeyg-msft !.

Thank you for Your answer, its very useful.

I got a question. How did you create table1- date?. I dont understand it

Andrés_0-1610988580173.png

 







 

Hi, @Anonymous 

 

You can download my sample file. The table is a calculate table,you can create whatever you want.

Like this:

Table = CALENDAR(MIN(table[date]),MAX(table[date]))
Table = CALENDARAUTO()

A date column will be automatically generated after creation.

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

parry2k
Super User
Super User

Hey @Anonymous , sorry for not getting back to you. Why not share pbix file with the expected output, make a smaller sample data, and remove any sensitive information before sharing, share it using one drive/google drive.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous depends on what is your end goal, it will help to decide the best way to solve it.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

I need a X axis. 

Andrés_0-1610566939898.png

 

Anonymous
Not applicable

@parry2k help pls 😕

parry2k
Super User
Super User

@Anonymous you cannot use the slicer value in the calculated table.

 

Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hii, thanks for your answer.

So what can i do? I need to create a column with the days of 1 to 28/30/31 (depends of the month) ... this according with the 2nd input value given.

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.