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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Miewmoo_33
Regular Visitor

SUMX & DATEADD give blank result

Hi everybody!

 

I 'm new in DAX and I get stusk with a dax formula I would like to understand and go futher of my understanding of DAX langage🙂:

 

My data model is quite simple.

I get a rate for each week and need to know if someone has 2 bad rates in a row (i.e someone who gets A bad rate (<0) for each of the 2 last weeks).

 

I thought about create a Sumx with calculate inside to get the rate of the previous week, than add this mesure with the one of the current week and test if I get a 2 values but the mesure of the previous week's rate guive me just blanks.😥

 

Mesure for rate of the previous week : 

BadRateS-1 = sumx(
            Tablefact,
calculate(
sum(Tablefact[isBadRate]),
DATEADD(Calendar[Date],
-7,
DAY)
)
)

 

 

StudentRateDateIsBadRate (O/1)
A-112/10/20201
A203/10/20200

 

 

Thanks a lot for your help.

Regards. 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Miewmoo_33 , Hope date table is marked as date table and have all required dates.

This should work
calculate(
sum(Tablefact[isBadRate]),
DATEADD(Calendar[Date],-7,DAY) )

 

Refer for week vs week my blogs


https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
Miewmoo_33
Regular Visitor

Thanks @amitchandak ,

Your formula works fine but I have got issue with adding that mesure with the first one in order to calculate the total of the last 2 weeks : Capture d’écran 2020-11-06 193635.jpg

 

 

total_Last2Weeks =
VAR _SumIndiv=
    CALCULATE ( IF ( ( test [IsBadS-1] + [IsBad] ) = 2"Warning" ) )
RETURN
  _SumIndiv

The level individual agregation and even more the total agregation get wrong.

 
 

Thnaks for helphing me again. 

 

 

 

amitchandak
Super User
Super User

@Miewmoo_33 , Hope date table is marked as date table and have all required dates.

This should work
calculate(
sum(Tablefact[isBadRate]),
DATEADD(Calendar[Date],-7,DAY) )

 

Refer for week vs week my blogs


https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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