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
Krishna_Mysore
Helper II
Helper II

Filter a table from two date columns from a another Table

Hi Guys

 

I have a Sales Tables  and a Project Schedule Table with Start and End Dates. Basically I want to calculate the sum of Qty by Site from my sales table during the Project Phase in months . 

 

To Illustrate

 

Site A has a  Project Start Date of 05/01/2018 and an End Date of 04/02/2018.  

Essentially the project impact is for Jan & Feb (2 months) disregarding difference in Days between two dates and then I want to sum the qty for these two months for Site A.  As shown below Site A has a qty of 91 (For Jan) and 79 (Feb) giving a total of 170.

Sample Data.pnghttps://drive.google.com/file/d/1pnTmBzKNghJ9WKKRk8y3T8Lmwv9EF7Is/view?usp=sharing

 

 

 

In order to achieve the aforesaid, I understand that ,

 

1) I need to Filter the the Sales Table by adopting either the Filter or CalculateTable

2) Nesting the above table refernce within SUMX funciton. 

 

I have attempted to write the measure but been stuggling to get it thorugh.  Any help is  much appreciated.

 

Sample PBIX is attached.

 

Thanks

 

 

 

 

1 ACCEPTED SOLUTION

Hi,

 

You are welcome.  If my reply helped, please mark it as Answer.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

 

You may download my PBI file from here.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks Ashish

Hi,

 

You are welcome.  If my reply helped, please mark it as Answer.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-shex-msft
Community Support
Community Support

Hi @Krishna_Mysore,

 

If you mean filter sales table based on related 'project' date range and calculate the summary value which has same site and account, you can try to use to following formulas.

 

Calculate table:

FilteredTable = 
FILTER (
    'Sales Table',
    [Period]
        IN CALENDAR (
            MINX (
                FILTER ( 'Project Schedule', [Site] = EARLIER ( 'Sales Table'[Site] ) ),
                'Project Schedule'[Start Date]
            ),
            MINX (
                FILTER ( 'Project Schedule', [Site] = EARLIER ( 'Sales Table'[Site] ) ),
                'Project Schedule'[End Date]
            )
        )
)

Measure:

Measure =
CALCULATE (
    SUM ( FilteredTable[Value] ),
    ALLSELECTED ( FilteredTable ),
    VALUES ( FilteredTable[Site] ),
    VALUES ( FilteredTable[Account] )
)

22.PNG

 

Regard,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thanks @v-shex-msft.  I had to slightly modiy the measure before adopting it. 

Much appreciated

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