Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Jyo27
Helper II
Helper II

Table issue

Hi everyone,

Need help to create measures . Can anyone please help to resolve this issue . 

input :

Category qtyweek
A112
B212
C212
D112
E3

11

 

F311

output:

current week Lastweek
AE
BF
C 
D 
count:4

count:2

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Jyo27 

You can refer to the following example

Create the following measures

Rank = COUNTROWS(FILTER(ALLSELECTED('Table'),[week] in VALUES('Table'[week])&&[Category ]<=SELECTEDVALUE('Table'[Category ])))
LastWeek =
VAR a =
    CALCULATE ( [Rank] )
VAR b =
    MAXX ( ALLSELECTED ( 'Table' ), [week] )
RETURN
    IF (
        SELECTEDVALUE ( 'Table'[week] ) = b,
        IF (
            CALCULATE (
                MAX ( 'Table'[Category ] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    [week]
                        = SELECTEDVALUE ( 'Table'[week] ) - 1
                        && [Rank] = a
                )
            )
                <> BLANK (),
            CALCULATE (
                MAX ( 'Table'[Category ] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    [week]
                        = SELECTEDVALUE ( 'Table'[week] ) - 1
                        && [Rank] = a
                )
            ),
            "null"
        )
    )
Currentweek_counts = COUNTROWS(FILTER(ALLSELECTED('Table'),[week]=MAXX(ALLSELECTED('Table'),[week]))) 
lastweek_counts = COUNTROWS(FILTER(ALLSELECTED('Table'),[LastWeek]<>"null"&&[week]=MAXX(ALLSELECTED('Table'),[week])))

Output

vxinruzhumsft_0-1693792259189.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Jyo27 

You can refer to the following example

Create the following measures

Rank = COUNTROWS(FILTER(ALLSELECTED('Table'),[week] in VALUES('Table'[week])&&[Category ]<=SELECTEDVALUE('Table'[Category ])))
LastWeek =
VAR a =
    CALCULATE ( [Rank] )
VAR b =
    MAXX ( ALLSELECTED ( 'Table' ), [week] )
RETURN
    IF (
        SELECTEDVALUE ( 'Table'[week] ) = b,
        IF (
            CALCULATE (
                MAX ( 'Table'[Category ] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    [week]
                        = SELECTEDVALUE ( 'Table'[week] ) - 1
                        && [Rank] = a
                )
            )
                <> BLANK (),
            CALCULATE (
                MAX ( 'Table'[Category ] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    [week]
                        = SELECTEDVALUE ( 'Table'[week] ) - 1
                        && [Rank] = a
                )
            ),
            "null"
        )
    )
Currentweek_counts = COUNTROWS(FILTER(ALLSELECTED('Table'),[week]=MAXX(ALLSELECTED('Table'),[week]))) 
lastweek_counts = COUNTROWS(FILTER(ALLSELECTED('Table'),[LastWeek]<>"null"&&[week]=MAXX(ALLSELECTED('Table'),[week])))

Output

vxinruzhumsft_0-1693792259189.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Jyo27
Helper II
Helper II

when i select week  ,it should show current week and previous week categories .

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors