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

DAX - Allocate Program Type

I am looking for some DAX syntax with the following logic

 

Table A - 

 

Columns - Work Order , Date Rec'd. Contract #, Net tons

 

Table B

 

Columns - Contract #, Net Tons, Program type

 

I am trying to allocate Program type to table A...the problem I'm having is Example - Contract # P-1234 has 10 work orders of X amount of tons and only a portion of those work orders should be allocated to a specfic progam.

 

Anyone have any thoughts....?

1 ACCEPTED SOLUTION

Hi @Anonymous

 

You may add the index in query editor.Please check the file.

1.png

Regards,

Cherie

Community Support Team _ Cherie Chen
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

14 REPLIES 14
Anonymous
Not applicable

Any takers? I can provide further information if needed. 

Hi @Anonymous

 

Could you share your sample data and expected output which could reproduce your scenario so that we could help further on it?You can also upload the .pbix file to OneDrive and post the link here. Do mask sensitive data before uploading.

How to Get Your Question Answered Quickly

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Anonymous
Not applicable

@v-cherch-msft above is a sample of the two tables and desired results. Apologies, I clicked post a little too quickly. 

Hi @Anonymous

 

You may link the two table first. Then you may create the calculated columns like below. Attached the sample file for your reference.

1.png

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-cherch-msft one last twist...:) In our line of business we recieve multiple deliveries on the same day....We have a unique ID (work order #) for each load. How would we work around this? 

 

The function created in the attachment doesn't seem to calculate correctly given duplicate dates. 

Hi @Anonymous

 

The way around this would be to create an index column to provide the uniqueness of rows. Use the index column in calculated column instead of the date column.If you need further help,please share a simplified data sample.

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

 

@v-cherch-msft - What would be the best way to index this? I tried to index by work order# but they are not sequenitally related to a specfic contract or date. 

 

 

Capture.PNG

 

 

Hi @Anonymous

 

It's always best to post your data in text/tabular format in addition to a screen capture. People trying to help can then readily copy the sample data and run some tests if they need to.

Based on my test,the above formula can be used for my scenario as below.Attached the sample file.Please let me know what's the issue for your data.

1.png

Regards,

Cherie

 

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Attached is were the problem in the last total is not allowing for proper allocation of the proram amount. I think it has to do with date receive. What would you recommend? @v-cherch-msft

 

Here is the data and screen shot...Also attached the pb file.

 

Syntax = 

LastTotal = CALCULATE(SUM(TableA[Total]),FILTER(TableA,TableA[Name]=EARLIER(TableA[Name])&&TableA[Date Receive]=EARLIER(TableA[Date Receive])-1))

 

Date ReceiveNameYearAmountTotalLastTotalProgramAContract No

1/2/2018a2018150150 1501
1/3/2018a20181503001501501
1/4/2018a20181504503001501
2/1/2018a20181501650 5001
1/5/2018a2018150600450501
1/6/2018a201815075060001
1/7/2018a201815090075001
1/8/2018a2018150105090001
1/9/2018a20181501200105001
1/10/2018a20181501350120001
1/11/2018a20181501500135001
1/2/2018b2018150150 1502
1/3/2018b20181503001501502
1/4/2018b20181504503001502
1/5/2018b2018150600450502
1/6/2018b201815075060002
1/7/2018b201815090075002
1/8/2018b2018150105090002

 

 

Capture.PNG

Anonymous
Not applicable

@v-cherch-msft one more thing. There are multiple reciecpts per day per the same contract. My apologies for not displaying that in the model. 

Hi @Anonymous

 

You may add the index in query editor.Please check the file.

1.png

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-cherch-msft Worked perfectly! Huge thanks!!

Hi @Anonymous

 

Could you tell me if your problem has been solved? If it is,kindly mark the helpful answer as a solution and welcome to share your own solution. More people will benefit from here. If not, please share more details for us so that we could help further on it.

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.