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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
tkavitha911
Helper III
Helper III

im trying to get this formula while im applying visualzation im getting this week as last week

ThisWeek_non_duty_paid =
VAR MaxWeekNum = MAX('FilteredTable'[week_num])

VAR ThisWeeknon_dutypaid = 
    CALCULATE(
        SUM('FilteredTable'[USD Non Duty Paid]),
        'FilteredTable'[week_num] = MaxWeekNum
    )

VAR Div = 1000000
VAR Result = DIVIDE(ThisWeeknon_dutypaid, Div)

RETURN
IF(
    HASONEVALUE('FilteredTable'[week_num]) &&
    VALUES('FilteredTable'[week_num]) = MaxWeekNum,
    Result,
    0
)

reference pic latest week data required previous weeks are 0 
tkavitha911_0-1724133691058.png

 

3 REPLIES 3
tkavitha911
Helper III
Helper III

by using matrix table i want to display last week =0 and this week i want to display data 

 

Anonymous
Not applicable

Hi, @tkavitha911 

Could you please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It is better if you can share a simplified pbix file. Thank you.

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi, @tkavitha911 

I am glad to help you.

 

May I ask what your specific semantic model looks like? 

Since you didn't give specific test data, I assumed some data based on your description: 

vfenlingmsft_0-1724208729080.png

 

Then optimized your DAX a bit: 

ThisWeek_non_duty_paid =
VAR MaxWeekNum =
    MAXX ( ALL ( 'FilteredTable' ), 'FilteredTable'[week_num] )
VAR ThisWeeknon_dutypaid =
    CALCULATE (
        SUM ( 'FilteredTable'[USD Non Duty Paid] ),
        'FilteredTable'[week_num] = MaxWeekNum
    )
VAR Div = 2
VAR Result =
    DIVIDE ( ThisWeeknon_dutypaid, Div )
RETURN
    IF ( MAX ( 'FilteredTable'[week_num] ) = MaxWeekNum, Result, 0 )

 

Here is my test results: 

vfenlingmsft_2-1724208826774.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.