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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
dhannaa
Helper IV
Helper IV

Power Query - Determine new and cancelled IDs from monthly Excel sheets

Hi all, 

 

What would be the easiest way to achieve the following goal?

My data is like this
3.PNG


I need to find out when some ID is New and when it is cancelled (exists in previous month but not anymore)
Capture.PNG


The end result I need is something like this:
2.PNG

Thanks in advance, appreciate your help! 🙂

Jenny

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@dhannaa , where is month data. You can create a measure using time intelligence and date calendar

 

MTD = CALCULATE(countrows(Table),DATESMTD('Date'[Date]))
last MTD = CALCULATE(countrows(Table),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month = CALCULATE(countrows(Table),previousmonth('Date'[Date]))
last MTD (complete) =  CALCULATE(countrows(Table),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
previous month value =  CALCULATE(countrows(Table),previousmonth('Date'[Date]))

diff = [MTD]-[last MTD]
diff % = divide([MTD]-[last MTD],[last MTD])

 

you can create a color measure on diff and use that in conditional formatting using "Field option"

Color Date = if([diff] >0 ,"lightgreen","red")

 

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-num...
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


Appreciate your Kudos.

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@dhannaa , where is month data. You can create a measure using time intelligence and date calendar

 

MTD = CALCULATE(countrows(Table),DATESMTD('Date'[Date]))
last MTD = CALCULATE(countrows(Table),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month = CALCULATE(countrows(Table),previousmonth('Date'[Date]))
last MTD (complete) =  CALCULATE(countrows(Table),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
previous month value =  CALCULATE(countrows(Table),previousmonth('Date'[Date]))

diff = [MTD]-[last MTD]
diff % = divide([MTD]-[last MTD],[last MTD])

 

you can create a color measure on diff and use that in conditional formatting using "Field option"

Color Date = if([diff] >0 ,"lightgreen","red")

 

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-num...
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


Appreciate your Kudos.

Thanks @amitchandak for super fast response.

Your solution sounds great and simple - don't know why I started this with Power Query in the first place :)!

Jenny

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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