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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
tkavitha911
Helper I
Helper I

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 I
Helper I

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

 

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.

v-fenling-msft
Community Support
Community Support

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.