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

Trying something: Vlookup and Sumifs in Excel and want to do it in Power BI

Hi..

I have two data sets: Market Sales and Contact Details

Sample here:https://drive.google.com/open?id=1ZL5yvqDhUJ3eb1D0pr7FKmUNyE3qgvAN

 

Structure: Market Sales

Market NameTime PeriodSales
C1201801100
C1201802120
---  

 

Contacts Data

MarketTime PeriodContact TypeNo. of Contacts
C1201801T110
C1201802T110
C1201801T220
C1201802T2

20

 

Calculations is to be like: If for time period 201802: Contacts (T1+T2){20+20}/Sales in C1 country {201801+201712+201711+201710+201709+201708} (Sum of sales in 6 prior months)

 

I have tried to create columns for calculating the rolling 6 prior months sales in market table (but failed) and then bring it to complaints table and using a measure like max(6mmtsales)/sum(contacts) {max because on joining the two tables, the contacts table will have multiple records of the same sales value}

 

Please can someone help me with this. TIA!

4 REPLIES 4
Anonymous
Not applicable

@Greg_DecklerCan you advice an approach on this.

amitchandak
Super User
Super User

My advice would convert time period to date in both tables and join with time dimesion and use the formula like the one in example below

New column in both tables

Date = date(left([time period],4),right([time period],2),1)

 

These are example formula, create like these

Rolling 6 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],ENDOFMONTH(Sales[Sales Date]),-6,MONTH)) 
Rolling 6 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date Filer],MAX(Sales[Sales Date]),-6,MONTH))  

 

Also, use a common Market dimension

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/

Anonymous
Not applicable

@amitchandakThis is the sample data and the process as well.

 

6MMT / YTD are the calculated columns I need. Emphasis on columns because data across two databases are at different levels and hence, measures won't work.

 

Logic is 6MMT is sum of sales for preceding 6 months or lesser in case data is not present.Ex: June 2019 is Dec 2018+Jan 2019+Feb 2019+Mar 2019+Apr 2019+May 2019

YTD is data from March of last fy to one month prior. Ex: May 2019 would be March 2019+April 2019.

Data is first 3 columns, I have added 2 additional columns with desired outputs.

 

CountryPeriodSales6MMT (6 Months Prior but Excluding This Month)YTD (From Last Year March to one month prior)
C12017118000
C1201712908080
C120180110017090
C1201802110270190
C1201803120380300
C1201804130500420
C1201805140630550
C1201806150690690
C1201807160750840
C12018081708101000
C12018091808701170
C12018101909301350
C12018112009901540
C120181221010501740

@Anonymous 

Please find the attached solution after the signature.

YTD you have to test on the bigger dataset as your description and expected output do not match

 

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.

Top Solution Authors