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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Month over Month

Hello All,

 

I have a very flat table

Product -------- Month

A ---------------- JAN

B ---------------- JAN

B ---------------- FEB

D ---------------- JAN

A ---------------- JAN

A ---------------- APR

E ---------------- JAN

 

How can I found out the count of products, which were sold in previous month but not is follwing month

Product A sold in Jan but not in FEB so I want COUNT of

A = 2 in JAN (becauae A was not sold in Feb but sold twice in Jan)

Do not Show B becaue it was sold in both months

 

I'll apprecite your help.

1 ACCEPTED SOLUTION
Phil_Seamark
Microsoft Employee
Microsoft Employee

HI @Anonymous

 

You could try this calculated table

 

Table 2 = 
VAR T1 = ADDCOLUMNS('Table',"MonthAsDateTime", DATEVALUE('Table'[Month] & "-2018"))
VAR LeftTable = SELECTCOLUMNS(T1,"Product",[Product],"MonthAsDateTime",[MonthAsDateTime])
VAR RightTable = SELECTCOLUMNS(T1,"Product",[Product],"MonthAsDateTime",EDATE([MonthAsDateTime],-1))
VAR Exceptions = EXCEPT(LeftTable,RightTable)
RETURN GROUPBY(Exceptions,[Product],[MonthAsDateTime],"C", SUMX(CURRENTGROUP(),1))

image.png

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

2 REPLIES 2
Phil_Seamark
Microsoft Employee
Microsoft Employee

HI @Anonymous

 

You could try this calculated table

 

Table 2 = 
VAR T1 = ADDCOLUMNS('Table',"MonthAsDateTime", DATEVALUE('Table'[Month] & "-2018"))
VAR LeftTable = SELECTCOLUMNS(T1,"Product",[Product],"MonthAsDateTime",[MonthAsDateTime])
VAR RightTable = SELECTCOLUMNS(T1,"Product",[Product],"MonthAsDateTime",EDATE([MonthAsDateTime],-1))
VAR Exceptions = EXCEPT(LeftTable,RightTable)
RETURN GROUPBY(Exceptions,[Product],[MonthAsDateTime],"C", SUMX(CURRENTGROUP(),1))

image.png

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

Awsome you are the man!

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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