Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Jacob_v_Jensen
New Member

Can't get subtotal to work with formula on fetched data

I have an table with data of sales orders, that get fetched every day. For this example, relevant is that i have an order number, a fetched date and a ordervalueamount for that giving day. 


I have tried something in the lines of:

VAR MaxFetchedDate = MAX('NavCurrentOrders (Fra SQL database)'[FetchedDate])
RETURN
    CALCULATE(
        SUM('NavCurrentOrders (Fra SQL database)'[OrderValueAmount]),
        'NavCurrentOrders (Fra SQL database)'[FetchedDate] = MaxFetchedDate
    )

This is the result for a giving order number in a matrix, with the fethced dates as months, where the formula doesn't work:

Jacob_v_Jensen_0-1713966645160.png

 

Any ideas to what to do?

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

This measure pattern should work

Measure = SUMX(VALUES(Calendar[Month name]),[your measure])


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

View solution in original post

7 REPLIES 7
Ashish_Mathur
Super User
Super User

Hi,

This measure pattern should work

Measure = SUMX(VALUES(Calendar[Month name]),[your measure])


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

Thanks for the reply

This works for the use case above, thanks!

You are welcome.


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

Hi @Jacob_v_Jensen 

 

Thanks for the reply from @DataNinja777 , please allow me to provide another insight:

You're overthinking this question, just change measure to:

SUM('NavCurrentOrders (Fra SQL database)'[OrderValueAmount])

The subtotal could be working fine.

 

Best Regards

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

Thanks for the reply, although this wouldn't work, as it wouldn't just sum the latest fetched data/row. A quick example of my dataset is such: 

Jacob_v_Jensen_0-1714028365104.png

so for april or just the latest date for that sake, it should only return 200 and 340 for the two order numbers. Just summing, would add all the values together giving 600 and 1020 in this example

DataNinja777
Super User
Super User

Hi @Jacob_v_Jensen 

 

What about something like below?

VAR MaxFetchedDate =
    MAX ( 'NavCurrentOrders (Fra SQL database)'[FetchedDate] )
RETURN
    CALCULATE (
        SUM ( 'NavCurrentOrders (Fra SQL database)'[OrderValueAmount] ),
        KEEPFILTERS ( 'NavCurrentOrders (Fra SQL database)'[FetchedDate] = MaxFetchedDate )
    )

 Best regards,

Thanks for the reply, with this the subtotal still doesn't work

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.