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! Learn more

Reply
flaviobdsti
Helper I
Helper I

Filter based metric sum

Hi Guys!
Please I need your help!
I have two measurements, LAST MONTH and CURRENT MONTH, both measures group sales values by CODE.


When I put the two measures together with the CODE field in a table, I have the result of the image below.

But now I need to create a measure that presents me the sum of the LAST MONTH column only when the respective
row of the CURRENT MONTH column is empty.

flaviobdsti_0-1676693319086.png

 

Can anyone help me?


Below my measurements:

CURRENT MONTH = CALCULATE(SUM(SALES[AMOUNT]),GROUPBY(ID, ID[CODE]))

 

LAST MONTH = CALCULATE([CURRENT MOTH],DATEADD(CALENDAR[DATE],-1,MONTH))

 

 

1 ACCEPTED SOLUTION

Hi,

This measure works.  Download the PBI file from here.

Measure = SUMX(FILTER(SUMMARIZE(CALCULATETABLE(VALUES('Table'[ID]),DATESBETWEEN(dimCalendar[Date],EDATE(MIN(dimCalendar[Date]),-1),min(dimCalendar[Date])-1)),'Table'[ID],"A",[CURRENT_MONTH],"B",[LAST MONTH]),[A]=0&&[B]>0),[B])

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

9 REPLIES 9
FreemanZ
Super User
Super User

hi @flaviobdsti 

what about:

[LAST MONTH] - [CURRENT MONTH]

  • Hi FreemanZ, unfortunately it's not possible because the values of the LAST MONTH and CURRENT MONTH can be different, then my result won't be correct. Example: see the line 2, CODE 6.

hi @flaviobdsti 

could you provide a minimum viable sample datasets for all the relevant tables and columns?

Thank you for answering my message

I created a .pbix file as an example. I put it in a repository, in the link below:

SAMPLE.PBIX 



flaviobdsti_0-1676743176070.png

 

Hi,

This measure works.  Download the PBI file from here.

Measure = SUMX(FILTER(SUMMARIZE(CALCULATETABLE(VALUES('Table'[ID]),DATESBETWEEN(dimCalendar[Date],EDATE(MIN(dimCalendar[Date]),-1),min(dimCalendar[Date])-1)),'Table'[ID],"A",[CURRENT_MONTH],"B",[LAST MONTH]),[A]=0&&[B]>0),[B])

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish Mathur,
I hope someday achieve your level. Thank you so much for your help. Worked perfectly!

You are welcome.  Thank you for your kind words.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

Not sure how much i can help but i would like to try.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish_Mathur

the problem is that this table is generated only from the insertion of the CODE column and the measures in this "virtual" table. My attempts to carry out a filter in measurements have failed. I would need something like, If the CURRENT MONTH column is equal to Blank() then it sums the corresponding values ​​of the LAST MONTH column. And at the end I need to put the result on a card.

Helpful resources

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

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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