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

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.