Forum Discussion
Date.IsInPreviousNDays M code question
- 9 years ago
You can either:
Add 1 step to your first query: select the value, so the output of the query will be 1 value and you can replace the 2 in your function by <NameOfYourFirstQuery>.
Or
Replace the value 2 in your function by: Table.FirstValue(<NameOfYourFirstQuery>).
I would prefer the first option.
Any query or function/formula that returns a numeric value could be used in place of a hard coded value. You could also refer it to the value returned by a previous step in the existing query or even a value from a specifc cell.
Based on your description of wanting to use a slicer, you are implying that you want the user to be able to select a value from said slicer and pass that into the filter argument for number of previous days to show. If that is the case, if you provide more detail about what it is you want to return after the slicer selection (an aggregation/calculation or a filtered table), we can assist you with the approach.
This is a representaion of the Excel Table. I'll followup with two more posts showing the Power Query side.
- Barry_Kelly9 years agoNew Member
This shows the results from the slicer in Power Query.
- Barry_Kelly9 years agoNew Member
The question is how to use the results from the parameter table in the Date.IsInPreviousNDays function.- MarcelBeug9 years agoCommunity Champion
You can either:
Add 1 step to your first query: select the value, so the output of the query will be 1 value and you can replace the 2 in your function by <NameOfYourFirstQuery>.
Or
Replace the value 2 in your function by: Table.FirstValue(<NameOfYourFirstQuery>).
I would prefer the first option.