cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

## Get previous month's sales of products that have sales on the current date

Hello community, I always guide myself from their publications but it is the first time I look for and look for and I do not find if they can help me with this problem that has come out:

As the title says I want to filter in some way the sales of the previous month that I get with this formula:

And only show sales from the previous month when they have sales in the current period. Some told me but condition if it is blank then do not put anything, if that can work when it is separated by category. But when they are grouped, the conditional does not work:

I am using as an example only one day I leave you a test pbix that I put together to try to perform the measurement.

1 ACCEPTED SOLUTION
Super User

Hi,

Write this measure

``Measure = SUMX(FILTER(VALUES('data pruebas'[DISTRIBUIDOR]),[Avance]>0),[Avance LM <])``

Regards,
Ashish Mathur
http://www.ashishmathur.com
8 REPLIES 8
Super User

I'm not sure how you wish to define 'current period' but if just generic across the whole model, then you need to provide that current period context by iterating on the Calendario table. Iterator functions end in X usually, such as SUMX.

I believe this formula is what you're looking for, but if not just reply with what the desired result should be:

Avance LM < AK =
SUMX(Calendario,
IF([Avance]<>BLANK(),
)
)

Note, this does not filter per Distribuidor each date period, but rather aggregates them all, so if that's something you need, we need to know EVERY dimension you want included and we need to add that to the context of the iterator measure.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Super User

Hi,

Try this measure

``````Avance LM < =

Regards,
Ashish Mathur
http://www.ashishmathur.com

As I tell you it is true that it serves when it is blank, but when they are grouped it no longer respects the condition the correct result should only be: 59947

Super User

Hi,

Write this measure

``Measure = SUMX(FILTER(VALUES('data pruebas'[DISTRIBUIDOR]),[Avance]>0),[Avance LM <])``

Regards,
Ashish Mathur
http://www.ashishmathur.com

Hello I worked well at the level records this formula but to show every day is not adding correctly the value, I was thinking of using a hasonevalue but it would not be the solution since this measure will be used in many ways and you would have to create many hasonvalue :

Super User

Which measure are you using for this screenshot? Have you tried my suggestion using the SUMX(Calendario ... this will provide the context for the totals row you're looking for.

Hello I worked well at the level records this formula but to show every day is not adding correctly the value, I was thinking of using a hasonevalue but it would not be the solution since this measure will be used in many ways and you would have to create many hasonvalue :

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Super User

Hi,

Regards,
Ashish Mathur
http://www.ashishmathur.com

WAO that great if it works on the PBix test tomorrow I will try it on the original PBix that weighs almost 900 MB thank you very much !

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

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

#### Fabric Community Update - August 2024

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

Top Solution Authors
Top Kudoed Authors