Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi All,
Hope everyone is well and safe in this pandemic. Iam new to Power BI and working on few calculations that need your help.
As shown above i have week and weekly confirmed cases as columns, "Up/down Trend Test" is a measure that returns if the cases from current and previous week are decreased or increased. logic is as below.
Solved! Go to Solution.
Hi @Anonymous ,
Try this:
StartWeek =
VAR ThisWeek =
MAX ( districts[Week] )
VAR LastWeek = ThisWeek - 1
VAR ThisTrend = [Up/Down Trend Test]
VAR LastTrend =
IF (
ThisWeek > 1,
CALCULATE ( [Up/Down Trend Test], districts[Week] = LastWeek )
)
RETURN
IF ( ThisTrend <> LastTrend, ThisWeek )
consecutive count =
VAR CalStartWeek =
MAXX (
FILTER (
ALLSELECTED ( districts[Week] ),
districts[Week] <= MAX ( districts[Week] )
),
[StartWeek]
)
VAR ThisWeek =
MAX ( districts[Week] )
RETURN
CALCULATE (
COUNTROWS ( districts ),
districts[Week] >= CalStartWeek
&& districts[Week] <= ThisWeek
)
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Try this:
StartWeek =
VAR ThisWeek =
MAX ( districts[Week] )
VAR LastWeek = ThisWeek - 1
VAR ThisTrend = [Up/Down Trend Test]
VAR LastTrend =
IF (
ThisWeek > 1,
CALCULATE ( [Up/Down Trend Test], districts[Week] = LastWeek )
)
RETURN
IF ( ThisTrend <> LastTrend, ThisWeek )
consecutive count =
VAR CalStartWeek =
MAXX (
FILTER (
ALLSELECTED ( districts[Week] ),
districts[Week] <= MAX ( districts[Week] )
),
[StartWeek]
)
VAR ThisWeek =
MAX ( districts[Week] )
RETURN
CALCULATE (
COUNTROWS ( districts ),
districts[Week] >= CalStartWeek
&& districts[Week] <= ThisWeek
)
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous ,
a new colum=
var _last = maxx(filter(Table, [Week] =earlier([Week]) -1) ,[Weekly confirmed cases])
return
if([Weekly confirmed cases] >_last , "up", "down")
I cant use this for calculated column because i want these values to be changed based on selection in slicers. moreover the formula you suggested seems to return down/up , but i need to print number which gives consecutive downs
@Anonymous , Create week Rank if you have year week, or use week. But prefer to move week to a separate table
new column in date/week table
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format
measures - use week in place week rank if needed
This Week = CALCULATE(sum('Table'[Weekly confirmed cases]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('Table'[Weekly confirmed cases]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))
Status measure =
if([ThisWeek] >[Last Week], "up", "down")
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 46 | |
| 42 | |
| 23 | |
| 18 |
| User | Count |
|---|---|
| 190 | |
| 122 | |
| 96 | |
| 66 | |
| 47 |