Forum Discussion
Display First and Last date based on two week index
- Anonymous4 years ago
Hi Anonymous ,
Please try to use the what-if parameter. You can interact with the variable as a slicer, and visualize and quantify different key values in your reports.
Here's my solution.
First, I created the Payroll Index from Jan20 on my own way.
Then, create a what-if parameter on the Modeling tab.
Set your own parameters according to your needs, here my maximum value is set to 26.
You can get a slider and a calculated table.
Create a relationship between two tables, then you can filter through the slider.
Now you can create a measure to get the text "1/1/2020 - 1/14/2020" to be displayed when the slider is selected to 0.
Measure = MIN('Calendar'[Date])&"-"&MAX('Calendar'[Date])Reference: Use what-if parameters to visualize variables - Power BI | Microsoft Docs
You can check more details from my attachment.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
The only problem with that is my "Date" table was created in DAX, thus has no table in power query.
You have new options:
1. Create date table in power query - heres the code to create table from 01-06-2020 until current day
let
Source = Table.FromList(List.Numbers(Number.From(#date(2020,1,6)),Number.From( Date.From( DateTime.LocalNow()))-Date.DayOfWeek( Date.From(DateTime.LocalNow()),Day.Monday)+7-Number.From(#date(2020,1,6))), Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Added Custom2" = Table.AddColumn(Source, "Payroll index from Jan2020", each Number.IntegerDivide(([Column1]-43836),7)),
#"Renamed Columns" = Table.RenameColumns( Table.TransformColumnTypes(#"Added Custom2",{{"Column1", type date}}),{{"Column1", "Date"}}),
Custom1 = List.Buffer(List.Zip({#"Renamed Columns"[Date],#"Renamed Columns"[#"Payroll index from Jan2020"]})),
Custom2 = #"Renamed Columns",
#"Added Custom" = Table.AddColumn(Custom2, "DateMin", each List.Min(List.Transform(List.Select(Custom1, (x)=>x{1}=[#"Payroll index from Jan2020"]), each _{0}))),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "DateMax", each List.Max(List.Transform(List.Select(Custom1, (x)=>x{1}=[#"Payroll index from Jan2020"]), each _{0})))
in
#"Added Custom1"2. Post your issue on DAX commands and tips forum.
Artur