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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Narasimha
Helper I
Helper I

Last 4 weeks data

Hi team..i want to display last 4 weeks data in column chart. At any point it is showing 4 weeks data.
Could you please help me with step by step process.
11 REPLIES 11
Narasimha
Helper I
Helper I

I was created new calculated column with below DAX

 

Last4Weeks = IF(DATEDIFF(ClosedTickets[PResolveDate],TODAY(),WEEK)<5 && MONTH(ClosedTickets[PResolveDate]) <> WEEKNUM(today()),"YES" ,"NO")

 

 

Hi @Narasimha,

 

Does above suggestion as I mentioned in my original post apply to your scenario? If you have resolved your issue, please kindly mark the corresponding reply as an answer so that it can benefit more people. If you still have any question, please feel free to ask.

 

Regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Team,

 

Am getting below results while using 4weeks DAX formula,

 

4weekdax.PNG

 

From above Image, Am getting extra week i.e Week28.. How to exclude Week28. I just display Last4Weeks data only.

 

Thnaks

Narasimha Reddy

 

Bumping up....

Hi,

Thank you for this solution.

I have a simalar problem, I'll try my best to explain.

I want to present the weekly measures of the 4 last weeks, the only difference is the I want it to be filtered by a slicer- to show only the 4 weeks back from the date on the slicer. (that the last week presented would be the date on the slicer, that it would be moving).

in my data I have both weekly and rolling 28 (4 last weeks) aggregated data.

I have a slicer of dates called 'period ends on', and I want it to show the 4 last weeks according to the slicer.

How can I do it?

Thanks a lot,

Liron

Can any one ping me v-lavala in pst hours..so that will work to resolve the issue
Else give ur alias..will ping me over im
Thanks
Narasinha

Hi @Narasimha,

 

Do you want to always display the last 4 weeks data in column chart?

 

Suppose there are these columns in source table: ClosedTickets[PResolveDate], ClosedTickets[Amount], ClosedTickets[Category]. Then, you should create a measure using this formula:

Sum Amount =
CALCULATE (
    SUM ( ClosedTickets[Amount] ),
    FILTER (
        ClosedTickets,
        DATEDIFF ( ClosedTickets[PResolveDate], TODAY (), WEEK ) < 5
    )
)

 

Drag this measure into value section.
1.PNG

 

If I have something misunderstood, please correct me.

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Phil_Seamark
Employee
Employee

Hi @Narasimha

 

Do you mean a rolling sum of the previous 4 weeks?  


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

alanhodgson
Solution Supplier
Solution Supplier

Hey @Narasimha,

 

First thing you want to do is make a new calculated column to hold the last day of every week:

 

Last Day of Week = Query[Date]+MOD(8-WEEKDAY(Query[Date],1),7)

 

Then, you can use the "Last Day of Week" (it is End Week2 in my dataset) column to create a filter on the chart. "End Date" in my data, should be the date you use in the formula above. This will show the last 4 weeks of the latest selected date in your slicer.

 

See below for the set up:

BI15.PNG

 

Hope this helps,

 

Alan

Anonymous
Not applicable

Hi @alanhodgson

 

Your soloution matches my requirment, but it is not working for me. I have created caluculated coloumnas like you said

 

Last Day of Week2 = 'Datekey'[Date]+MOD(8-WEEKDAY('Datekey'[Date],1),7)

Hey @Anonymous,

 

Make sure you are putting the Date field that you use for the calculated column into the "Axis" part of the visual.

 

Other than that, it looks correct to me. I was also able to recreate the same column again and it worked fine.

 

Hope this helps,

 

Alan

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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