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
AdmanPowerBI
Frequent Visitor

Multiple Filters with SUMX

Hi There,

 

I hope that I have described this correctly but here it goes:

 

I'm working on a solution to find previous year-to-date and I found that Kasper On BI had a great solution. I have a new dataset which includes much higher details on my sales data, down to individual lines and then BOM levels of our product build up. Here is an example of the dataset:

OrderNumberLineItemProductBOM_IDLineItemPriceInvoiceDate
40000176000001001952.0303/18/2016
40000171000001011952.0303/18/2016
40000171001121952.0303/18/2016
40000171100031952.0303/18/2016
40000171401541952.0303/18/2016
4000019600000100863.5303/18/2016
4000019100000101863.5303/18/2016
4000019100112863.5303/18/2016
4000019110003863.5303/18/2016

It is a bit cumbersome but I am able to find my order value with the following measure:

$OrderValue = SUMX(FILTER(OrderTable,BOM_ID=0),LineItemPrice))

 

When I use the attempt to use Kasper's Sales sameperiod measure:

Sales sameperiod =
VAR startyear =
    STARTOFYEAR ( ‘Calendar'[Date] ) – 365
VAR enddate =
    LASTDATE ( Sales[Date] ) – 365
RETURN
    CALCULATE (
        SUM ( Sales[sales] ),
        DATESBETWEEN ( ‘Calendar'[Date], startyearenddate )
    )

 

I am having trouble returning a value over that time period that takes into account both the date filter and to just select BOM_ID=0.

 

Thanks for any help you can give!

1 ACCEPTED SOLUTION
calerof
Impactful Individual
Impactful Individual

Hi @AdmanPowerBI ,

 

Check this pbix file.

 

Regards,

 

Fernando

 

View solution in original post

6 REPLIES 6
calerof
Impactful Individual
Impactful Individual

Hi @AdmanPowerBI ,

 

Check this pbix file.

 

Regards,

 

Fernando

 

Hi @calerof ,

 

Thank you very much! That worked 🙂

I can honestly say I'm not quite sure why and if you have time, I would love to know. Again thanks so much.

 

Adam

Hi @AdmanPowerBI ,

 

First and foremost, if you review the pbix file, a Calendar table was added to the model and marked as Date Table.

 

Then, in the Order Value measure I used an explicit measure to sum the line item price, instead of using the implicit measure LineItemPrice.

 

Lastly, in the Sales Same Period measure I used the Order Value measure in the RETURN calculation, instead of SUM ( Sales[sales] ).

 

That was pretty much it.

 

Best regards,

 

Fernando

 

Again thank you!

 

Greg_Deckler
Super User
Super User

See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks Greg!

I have been working on a solution with CALCULATETABLE although I haven't quite solved it yet. I will keep plugging away and let you know how this goes.

Adam

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.