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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
joeyrobbins
Frequent Visitor

Sharing a montly value between all rows in your filtered table

Hi!

 

Going a little crazy trying to figure this out - I have a table of values split by month and by sales channel called 'Overheads' (see below).

joeyrobbins_0-1661334667369.png

What I want to do is to pull these figures into a field on my main orders database, which has line-by-line orders - matching the order date and the sales channel - but also split between the total number of orders in that channel for that month.

 

joeyrobbins_1-1661340235870.png

As you can see above, I've managed to pull through the value on each line corresponding to the month of order and the channel, (using 'RELATED' - adding a month/channel concatenation to my data query) -  but what I want to do is to divide this value by the total number of orders in that month for that channel - so that when it is summed together in a summary matrix - it produces the total 'direct cost' for the month, but will also change proportionally day by day if your date filter is not over the whole month. Any help would be appreciated!

1 ACCEPTED SOLUTION
v-kkf-msft
Community Support
Community Support

Hi @joeyrobbins ,

 

Please try these measures.

 

TotalCosts = 
CALCULATE (
    SUM ( Overheads[Value] ),
    FILTER (
        Overheads,
        Overheads[Costs] = MAX ( 'Table'[Channel Name] )
            && Overheads[Month] = MAX ( 'Table'[Order YearMonth] )
    )
)
M_costs =
IF (
    ISFILTERED ( 'Table'[Order No.] ),
    DIVIDE (
        [TotalCosts],
        CALCULATE (
            COUNTROWS ( 'Table' ),
            ALLSELECTED ( 'Table' ),
            VALUES ( 'Table'[Channel Name] ),
            VALUES ( 'Table'[Order YearMonth] )
        )
    ),
    [TotalCosts]
)

vkkfmsft_0-1661743476827.png


If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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

2 REPLIES 2
v-kkf-msft
Community Support
Community Support

Hi @joeyrobbins ,

 

Please try these measures.

 

TotalCosts = 
CALCULATE (
    SUM ( Overheads[Value] ),
    FILTER (
        Overheads,
        Overheads[Costs] = MAX ( 'Table'[Channel Name] )
            && Overheads[Month] = MAX ( 'Table'[Order YearMonth] )
    )
)
M_costs =
IF (
    ISFILTERED ( 'Table'[Order No.] ),
    DIVIDE (
        [TotalCosts],
        CALCULATE (
            COUNTROWS ( 'Table' ),
            ALLSELECTED ( 'Table' ),
            VALUES ( 'Table'[Channel Name] ),
            VALUES ( 'Table'[Order YearMonth] )
        )
    ),
    [TotalCosts]
)

vkkfmsft_0-1661743476827.png


If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-kkf-msft That's amazing! There's a couple of functions I haven't used before in those measures, i.e. ALLSELECTED and ISFILTERED which I'll get my head around.

This is much further than I'd managed - the only thing is that when filtered over 2 months on a summary table - only the most recent month value appears. Do you know how I can modify these date measures to combine the values when two months are in the filter?

Many thanks again, 

Joey

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.