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.
I have a table that has columns ValidFromDate, EndDate, ResultID, and ResulType.
I want to filter the table by today's date, and today's value should contain
Today >= ValidFromDate & Today<= EndDate.
For example, In SQL we can use the query
case when getdate() >= ValidFromDate and GETDATE() <= EndDate then 1 else 0 end as active
Is there a way to do that in Power BI?
Regards,
Solved! Go to Solution.
@Anonymous
Are you trying to create a copy of the data or calculate a measure with the filter applied?
For a copy of the table you could use
Table =
FILTER ( YourTable,
YourTable[ValidFromDate] <= TODAY() && YourTable[EndDate] >= TODAY()
)
This code would go in as a calculated table.
If you are doing a calculation and want to apply the filter to the calc it looks like this.
Measure =
CALCULATE(
COUNTROWS( YourTable ),
YourTable[ValidFromDate] <= TODAY(),
YourTable[EndDate] >= TODAY()
)
If this solves your issues please mark it as the solution. Kudos 👍 are nice too.
Hi,
Using the Query editor, you should create a single column of Date from the 2 date columns. Then build a calendar table and build a relationship from the Date column of the transformed table to the Date column of the Calendar Table. Build a Date slicer from the Date column of the Calendar Table.
Hope this helps.
Hi,
Using the Query editor, you should create a single column of Date from the 2 date columns. Then build a calendar table and build a relationship from the Date column of the transformed table to the Date column of the Calendar Table. Build a Date slicer from the Date column of the Calendar Table.
Hope this helps.
@Anonymous
Are you trying to create a copy of the data or calculate a measure with the filter applied?
For a copy of the table you could use
Table =
FILTER ( YourTable,
YourTable[ValidFromDate] <= TODAY() && YourTable[EndDate] >= TODAY()
)
This code would go in as a calculated table.
If you are doing a calculation and want to apply the filter to the calc it looks like this.
Measure =
CALCULATE(
COUNTROWS( YourTable ),
YourTable[ValidFromDate] <= TODAY(),
YourTable[EndDate] >= TODAY()
)
If this solves your issues please mark it as the solution. Kudos 👍 are nice too.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |