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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register 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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.