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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
H_insight
Helper V
Helper V

Comparison between last week status and this week status

Hello,

 

In my dummy sample dataset, I am trying to compare last week's status and this week's status for each of the selected employees.

 

For example, when I select 10/01/2022, I would expect to show the status values for the current week (10 to 14/01/2022) and last week (03 to 07/01/2022):

 

HeshamK_0-1646757540228.png

 

Hope the above ilsturation helps, but if not, happy to answer any questions.

 

Sample PBIX file.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @H_insight,

Perhaps you can try to use the following measure formulas if helps:

Current Week =
VAR _currentDate =
    MAX ( 'Calendar'[Date] )
RETURN
    CALCULATE (
        CONCATENATEX ( VALUES ( Data[Status] ), [Status], "," ),
        FILTER (
            ALLSELECTED ( 'Data' ),
            YEAR ( 'Data'[Date] ) = YEAR ( _currentDate )
                && WEEKNUM ( 'Data'[Date], 2 ) = WEEKNUM ( _currentDate, 2 )
        ),
        VALUES ( 'Data'[EmpID] )
    )

Previous Week =
VAR _currentDate =
    MAX ( 'Calendar'[Date] )
VAR _previousDate =
    _currentDate - WEEKDAY ( _currentDate, 2 )
RETURN
    CALCULATE (
        CONCATENATEX ( VALUES ( Data[Status] ), [Status], "," ),
        FILTER (
            ALLSELECTED ( 'Data' ),
            YEAR ( 'Data'[Date] ) = YEAR ( _previousDate )
                && WEEKNUM ( 'Data'[Date], 2 ) = WEEKNUM ( _previousDate, 2 )
        ),
        VALUES ( 'Data'[EmpID] )
    )

If the above does not help, can you please share some dummy data with raw table structure and paste it here with table format? (I can't view the shared link) It should help us clarify the data structure and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

View solution in original post

4 REPLIES 4
H_insight
Helper V
Helper V

I am just thinking loudly here, maybe I should add a calculated column with a lookupvalue to return last week's text/value for [Status] into the table? 


I tried to create the below measure, but with no luck (I could be wrong) ....

Test 2 = 
Var _currentweek = SELECTEDVALUE('Calendar'[Week number])
Var _currentyear = SELECTEDVALUE('Calendar'[Year])
Var _maxweek = CALCULATE(MAX('Calendar'[Week number]),ALL('Calendar'))
Var _filter =
    FILTER(ALL('Calendar'),
        'Calendar'[Week number] = SELECTEDVALUE('Calendar'[Week number]) -1 &&
        'Calendar'[Year] = SELECTEDVALUE('Calendar'[Year]))
RETURN
    CALCULATE (
        DISTINCT ( Data[Status] ),
        FILTER(ALL('Calendar'),
        'Calendar'[Week number] < _currentweek &&
        'Calendar'[Year] = SELECTEDVALUE('Calendar'[Year]))
    )

Any idea's?

Anonymous
Not applicable

HI @H_insight,

Perhaps you can try to use the following measure formulas if helps:

Current Week =
VAR _currentDate =
    MAX ( 'Calendar'[Date] )
RETURN
    CALCULATE (
        CONCATENATEX ( VALUES ( Data[Status] ), [Status], "," ),
        FILTER (
            ALLSELECTED ( 'Data' ),
            YEAR ( 'Data'[Date] ) = YEAR ( _currentDate )
                && WEEKNUM ( 'Data'[Date], 2 ) = WEEKNUM ( _currentDate, 2 )
        ),
        VALUES ( 'Data'[EmpID] )
    )

Previous Week =
VAR _currentDate =
    MAX ( 'Calendar'[Date] )
VAR _previousDate =
    _currentDate - WEEKDAY ( _currentDate, 2 )
RETURN
    CALCULATE (
        CONCATENATEX ( VALUES ( Data[Status] ), [Status], "," ),
        FILTER (
            ALLSELECTED ( 'Data' ),
            YEAR ( 'Data'[Date] ) = YEAR ( _previousDate )
                && WEEKNUM ( 'Data'[Date], 2 ) = WEEKNUM ( _previousDate, 2 )
        ),
        VALUES ( 'Data'[EmpID] )
    )

If the above does not help, can you please share some dummy data with raw table structure and paste it here with table format? (I can't view the shared link) It should help us clarify the data structure and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

VahidDM
Super User
Super User

Hi @H_insight 

 

Please check this link, I think it would be helpful:

 

https://www.vahiddm.com/post/weekly-time-intelligence-dax

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Hi @VahidDM 

 

Thanks for sharing the link.

 

I am afraid that I am looking to compare/return "Text" with "Text" and not a scalar number.

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.