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.
Hi There,
I am fairly new to power BI and trying to figure this out.. I want to create a date table that will have a series how collumns that show a "Yes" or "No" value based on specfied date ranges e.g 1 day ago, 2 days ago, last week, last month etc.
I have managed to get days working fine but I am struggling to get Last Month and Last week. Any idea on the formula I should use for these?
This is the formula I use to calculate yesterday:
Yesterday =
IF (
YEAR ( [Date] ) = YEAR ( TODAY () )
&& DAY ( [Date] ) = DAY ( TODAY () -1 ),
"Yes",
"No"
)
Any help would be much appricated! Thanks
Solved! Go to Solution.
Hi Xioxin,
Thanks for the reply. I tried that and still get the same error.
The "," is working when I use it in other formulas. Example this works:
Yesterday =
IF (
YEAR ( [Date] ) = YEAR ( TODAY () )
&& DAY ( [Date] ) = DAY ( TODAY () -1 ),
"Yes",
"No"
)
@Greg_Deckler , @Mich I was unable to get this to work as written above, but was able to adjust the parenthises in the formula to get it to work:
Perhaps:
Last Month = IF ( YEAR ( [Date] ) = YEAR ( TODAY () ) && MONTH( [Date] ) = MONTH( TODAY ()) -1 ), "Yes", "No" )
Last Week =
IF (
YEAR ( [Date] ) = YEAR ( TODAY () )
&& WEEKNUM ( [Date] ) = WEEKNUM ( TODAY ()) -1 ),
"Yes",
"No"
)
Hi, how will you obtain the first date and last dates of last 2 weeks for the first , second and third weeks of January?
Hi Greg,
Thank you for your reply. I tried your suggestion but I get the following error
The syntax for ',' is incorrect. (DAX(IF (YEAR ( [Date] ) = YEAR ( TODAY () )&& MONTH( [Date] ) = MONTH( TODAY ()) -1 ),"Yes","No"))).
Thanks
Hi @Anonymous,
It seems like your system not support ',' as separator, you can try to use ';' to instead ','.
Regards,
Xiaoxin Sheng
Hi Xioxin,
Thanks for the reply. I tried that and still get the same error.
The "," is working when I use it in other formulas. Example this works:
Yesterday =
IF (
YEAR ( [Date] ) = YEAR ( TODAY () )
&& DAY ( [Date] ) = DAY ( TODAY () -1 ),
"Yes",
"No"
)
Helo, Correct formula below -there was an extra ) next to today
Last Month = IF ( YEAR ( [Date] ) = YEAR ( TODAY () ) && MONTH( [Date] ) = MONTH( TODAY () -1 ), "Yes", "No" )
Last Week =
IF (
YEAR ( [Date] ) = YEAR ( TODAY () )
&& WEEKNUM ( [Date] ) = WEEKNUM ( TODAY () -1 ),
"Yes",
"No"
)
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 |
---|---|
111 | |
95 | |
80 | |
68 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |