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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Help with Dax expression.

Hello and a greeting to everyone, I am new to the forum and I do not know if this goes in the right section. For the last few months I've been researching how Power Bi works and getting a little bit into DAX.

On a website where there is a powerbi course, I find this expression that I have applied to a table for the calculation of the kilometers made the previous week:

Kms. Anterio week ? calculate([kmmeters],filter('Main table'),countrows(filter('Main table',earlier('Main table'[DATE])-dateadd(calendar[Date],-7,DAY)))))
The fact is that the expression works (as long as there are kilometers made daily), but I do not understand the following, no matter how many laps I give it:
- I know how the earlier expression works and what it returns, in this case it would return the rows a week before to the updated row.
- Countrows returns the number of rows that meet that condition, so as far as my knowledge reaches, it returns a scalar.
- Now it arrives, the part I don't have,
filter(all('Tabla principal'),countrows(filter('T.......................
Here I guess that in the filter, I select the entire table without any filter applied to it, but the second argument of filter is the countrows that returns a scalar ( a number ) and in theory the second argument of filter is a condition, a Boolean expression. if I do a direct filter and in the second argument I place a number, power bi gives me error, but if I do it with filter(all( 'Main table'), countrows...........) if I support it.
Would anyone know where I commit the failure to analyze it?
Thank you in advance and a greeting.
1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , Not very clear to me for WOW please refer my blog

https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors