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, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
PeterVachon
Frequent Visitor

Trying to ma the difference between 2 columns in different tables in a measure

Hi, 

I have 2 tables 

1) Sales tables (daily)

2) Forecast tables (monthly)

(Both are link to my look up tables :  product, customer, calendar)

 

I am trying to have a measure that would help my compare the total per different caterogies (1st step is the SalesRep) 

But every measure i've tried only calculate totals and i cannot use my different filter

Ex :  Want to compare total of sales at the end of may per REP vs their forecast.   Then i'll want to compare client by client... etc... so it has to be dynamic based on the date. 

 

Any tips on how to write this ?  I am really new with Dax and struggling a bit here. 

 

2 ACCEPTED SOLUTIONS

@PeterVachon ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Need to try with data

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

v-yangliu-msft
Community Support
Community Support

Hi  @PeterVachon ,

This is the data I created:

Sales tables:

v-yangliu-msft_0-1621928571398.png

Forecast tables:

v-yangliu-msft_1-1621928571400.png

look up tables:

v-yangliu-msft_2-1621928571404.png

Here are the steps you can follow:

1. Create measure.

alltoal =
var _select=
SELECTEDVALUE('look up table'[date])
return
CALCULATE(SUM('Sales tables'[amount]),FILTER(ALL('Sales tables'),'Sales tables'[Customer]=MAX('Sales tables'[Customer])&&'Sales tables'[Month]=MONTH(_select)))
Forecastamount =
var _select=SELECTEDVALUE('look up table'[date])
return
CALCULATE(SUM('Forecast tables'[Amount]),FILTER(ALL('Forecast tables'),'Forecast tables'[monthly]=MONTH(_select)&&'Forecast tables'[Customer]=MAX('Forecast tables'[Customer])))
Flag =
IF(MAX('Sales tables'[date]) in SELECTCOLUMNS('look up table',"1",[date]),1,0)
Flag1 =
IF(MAX('Forecast tables'[monthly]) in SELECTCOLUMNS('look up table',"1",MONTH('look up table'[date])) ,1,0)

2. Put [Flag] and [Flag1] into the Filter of the corresponding visual object respectively, is=1, apply filter.

v-yangliu-msft_3-1621928571405.png

3. Put [date] of the look up table table into the slicer, according to the selected date, to display the corresponding total sales and monthly forecast value, and compare

4. Result:

v-yangliu-msft_4-1621928571410.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-yangliu-msft
Community Support
Community Support

Hi  @PeterVachon ,

This is the data I created:

Sales tables:

v-yangliu-msft_0-1621928571398.png

Forecast tables:

v-yangliu-msft_1-1621928571400.png

look up tables:

v-yangliu-msft_2-1621928571404.png

Here are the steps you can follow:

1. Create measure.

alltoal =
var _select=
SELECTEDVALUE('look up table'[date])
return
CALCULATE(SUM('Sales tables'[amount]),FILTER(ALL('Sales tables'),'Sales tables'[Customer]=MAX('Sales tables'[Customer])&&'Sales tables'[Month]=MONTH(_select)))
Forecastamount =
var _select=SELECTEDVALUE('look up table'[date])
return
CALCULATE(SUM('Forecast tables'[Amount]),FILTER(ALL('Forecast tables'),'Forecast tables'[monthly]=MONTH(_select)&&'Forecast tables'[Customer]=MAX('Forecast tables'[Customer])))
Flag =
IF(MAX('Sales tables'[date]) in SELECTCOLUMNS('look up table',"1",[date]),1,0)
Flag1 =
IF(MAX('Forecast tables'[monthly]) in SELECTCOLUMNS('look up table',"1",MONTH('look up table'[date])) ,1,0)

2. Put [Flag] and [Flag1] into the Filter of the corresponding visual object respectively, is=1, apply filter.

v-yangliu-msft_3-1621928571405.png

3. Put [date] of the look up table table into the slicer, according to the selected date, to display the corresponding total sales and monthly forecast value, and compare

4. Result:

v-yangliu-msft_4-1621928571410.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

PeterVachon
Frequent Visitor

To better explain,  I've tried splitting up my formual to see what is going on.

1st part of my formula isn't working correctly it returns the TOTAL sales YTD and doesn't spread per REP as i would like it to in my matrix, 

 

Measure = CALCULATE(sumx(FILTER('Sales','Sales'[invoicedt] >= 2021-01-01),'Sales'[NET]))
 
It's probably not the right operator... calculatetable also deliver the sames results. 
amitchandak
Super User
Super User

@PeterVachon , Not very clear on the issue. Becuase if you have calendar table, joined to both tables, then you can compare actual and forecast values monthly 

 

if sales rep is not a common dimesion, then you can not compare that.

 

If handeling date is an issue refer

Distributing/Allocating the Monthly Target(Convert to Daily Target): Measure ( Daily/MTD): https://community.powerbi.com/t5/Community-Blog/Power-BI-Distributing-Allocating-the-Monthly-Target-...

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

What i am trying to do is write a measure that with take my Total Sales -  Forecast and be able to spread it out per REP or customer.  Depending on how I present my Matrix/Table.   If i only use a quick measure it doesn't work and doesn't spread correctly. 

 

But, I keep getting only the TOTAL.

 

My filter regardings the dates is working well... no worry. 

 

BTW : Thx for your link this will come up handy real soon 😉

@PeterVachon ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Need to try with data

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

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

October NL Carousel

Fabric Community Update - October 2024

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