Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
I have a table and a slicer (showing today’s date by default). I want when a user select a date from slicer, the table shows the closest date (date column in the table visual) to the selected in slicer.
I tried to create a measure that shows max date less than selected date in slicer:
Also a filter that shows which records should show and which is not:
Filter = IF(FORMAT('BankCard AccountSummary'[Date], "dd/MM/YYYY") = FORMAT([max dates], "dd/MM/YYYY") ,1,0)
And used that filter in filter section.
The “max dates” shows me the correct number but when I want to compare it with date column in the table visual, the filter measure doesn’t show correct data.
I tried to convert both “max dates” and date column to the same format both still didn’t work.
Solved! Go to Solution.
Hi @armehraban
Use the following Dax to get the "max date" column
max date =
VAR SelectedDate = SELECTEDVALUE('Start Date'[Date])
VAR ClosestDate =
CALCULATE(
MAX('Table'[Date]),
FILTER(
ALL('Table'),
'Table'[Date] <= SelectedDate
)
)
RETURN
IF(
MIN('Table'[Date]) <= SelectedDate,
ClosestDate,
BLANK()
)
Use the following Dax to get the "Date Difference Measure" column
Date Difference Measure =
VAR SelectedDate = SELECTEDVALUE('Start Date'[Date])
VAR ClosestDateMeasure =
CALCULATE(
MAX('Table'[Date]),
FILTER(
ALL('Table'),
'Table'[Date] <= SelectedDate
)
)
RETURN
DATEDIFF(ClosestDateMeasure, MAX('Table'[Date]), DAY)
Use the following Dax to get the "Date Format Match Measure" column
Date Format Match Measure =
IF (
FORMAT(MAX('Table'[Date]), "dd/mm/yyyy") = FORMAT([max date], "dd/mm/yyyy"),
1,
0
)
This is the result you want
If I misunderstand what you mean, please provide your sample PBIX file along with the result you want
Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @armehraban
Use the following Dax to get the "max date" column
max date =
VAR SelectedDate = SELECTEDVALUE('Start Date'[Date])
VAR ClosestDate =
CALCULATE(
MAX('Table'[Date]),
FILTER(
ALL('Table'),
'Table'[Date] <= SelectedDate
)
)
RETURN
IF(
MIN('Table'[Date]) <= SelectedDate,
ClosestDate,
BLANK()
)
Use the following Dax to get the "Date Difference Measure" column
Date Difference Measure =
VAR SelectedDate = SELECTEDVALUE('Start Date'[Date])
VAR ClosestDateMeasure =
CALCULATE(
MAX('Table'[Date]),
FILTER(
ALL('Table'),
'Table'[Date] <= SelectedDate
)
)
RETURN
DATEDIFF(ClosestDateMeasure, MAX('Table'[Date]), DAY)
Use the following Dax to get the "Date Format Match Measure" column
Date Format Match Measure =
IF (
FORMAT(MAX('Table'[Date]), "dd/mm/yyyy") = FORMAT([max date], "dd/mm/yyyy"),
1,
0
)
This is the result you want
If I misunderstand what you mean, please provide your sample PBIX file along with the result you want
Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
That should work as you described.
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information or anything not related to the issue or question.
If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
112 | |
112 | |
105 | |
94 | |
58 |
User | Count |
---|---|
174 | |
147 | |
136 | |
102 | |
82 |