The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello Everyone, I need help with this.
I have a date in my table, with dates ranging from 2019 to today. My requirement is to display Measure1 for dates from the previous Sunday to the previous Saturday, and Measure2 for all other dates.
How can I achieve this?
Thank You,
Ajit
Create a calculated column to identify the week range:
DAX
WeekRange =
VAR CurrentDate = 'Table'[Date]
VAR PreviousSunday =
IF(
WEEKDAY(TODAY(), 2) = 7,
TODAY() - 7,
TODAY() - WEEKDAY(TODAY(), 2)
)
VAR PreviousSaturday = PreviousSunday + 6
Create a measure to display Measure1 or Measure2 based on the week range:
DAX
DisplayMeasure =
IF(
MAX('Table'[WeekRange]) = "PreviousWeek",
[Measure1],
[Measure2]
)
Proud to be a Super User! |
|