Hello All,
I have a calendar table link to a sales fact table.
On the front-end, I want to set the month with the latest record to be the the default date in my date slicer.
The field in the date slicer are the fields "Month" "Year" that come from the calendar date.
The calendar table looks like this:
Any idea how to solve this.
I have found this video https://www.youtube.com/watch?v=5dN4SqufENE but I don't know where to implement the formula Today = List.Max( SalesData[Order Date])
Thanks,
Solved! Go to Solution.
Hi @Chrisjr ,
List.Max() is the M function which you can use in the PowerQuery editor.
You may also consider creating these two calculated columns.
Month with Current =
IF (
YEAR ( MAX ( 'Table'[Date] ) ) = 'Calendar'[Year]
&& MONTH ( MAX ( 'Table'[Date] ) ) = 'Calendar'[Month Number],
"Current",
'Calendar'[Month]
)
Sort one column by another column in Power BI
Sort By for Month with Current =
IF (
IF (
YEAR ( MAX ( 'Table'[Date] ) ) = 'Calendar'[Year]
&& MONTH ( MAX ( 'Table'[Date] ) ) = 'Calendar'[Month Number],
"Current",
'Calendar'[Month]
) = "Current",
0,
MONTH ( 'Calendar'[Date] )
)
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
thanks a lot @v-cgao-msft and @amitchandak .
Thanks @amitchandak for the video, very helpful
Hi @Chrisjr ,
List.Max() is the M function which you can use in the PowerQuery editor.
You may also consider creating these two calculated columns.
Month with Current =
IF (
YEAR ( MAX ( 'Table'[Date] ) ) = 'Calendar'[Year]
&& MONTH ( MAX ( 'Table'[Date] ) ) = 'Calendar'[Month Number],
"Current",
'Calendar'[Month]
)
Sort one column by another column in Power BI
Sort By for Month with Current =
IF (
IF (
YEAR ( MAX ( 'Table'[Date] ) ) = 'Calendar'[Year]
&& MONTH ( MAX ( 'Table'[Date] ) ) = 'Calendar'[Month Number],
"Current",
'Calendar'[Month]
) = "Current",
0,
MONTH ( 'Calendar'[Date] )
)
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
@Chrisjr , Create a new column like this in DAX and use this it slicer and save on max date( column in date table)
Date Type = SWITCH(TRUE(),'Date'[Date]=max(fact[date]),"Max Date"
,'Date'[Date]&"")
Default Date Today/ This Month / This Year: https://www.youtube.com/watch?v=hfn05preQYA