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

Dynamic total measure , based on slicer

Hi, I'm trying to calculate dynamic total, for the total orders palced YTD (i already have a seperate column for the total by week), also there is multiple customers in slicer. When i select the slicer, i want the dynamic total to change . 

 

I'm trying to do this to get value for denominator, so i can do another dynamic total on "ordes < 1 day" and use it as numerator, so I can further calculate a % to keep below actual % a flat line (as on that week, rather than what i have currently shows the % of that week, see beloe image), which is dyanmic based on slicer and keep chnaging as more data is being added. 

 

My main intension is to give an YTD actual %, linked to slicer - any other way ?

 

gav1991_1-1695420824733.png

 

I also tried, below DAX, by creating a seperate table for customer. it seems not working

 

Dynamic Total Orders = CALCULATE(
SUM('Order'[Total No of Orders]),
FILTER(
ALLSELECTED('Order'[Customer]),
ALLSELECTED(Customer[Customer])
)
)

 

1 ACCEPTED SOLUTION

Hi @gav1991 ,

 

Please try below code to create a [Acutal %] measure.

Actual % =
CALCULATE (
    DIVIDE (
        SUM ( 'Order'[Orders placed ≤ 1 Day] ),
        SUM ( 'Order'[Total No of Orders placed] )
    ),
    ALLEXCEPT ( 'Order', 'Order'[Customer] )
)

Result is as below.

vrzhoumsft_0-1695709023934.png

 

Best Regards,
Rico Zhou

 

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

5 REPLIES 5
gav1991
Frequent Visitor

@123abc  Hiya, thanks for your reply. However, i do not have a useful date in my data, i have from and to, however the data is built on the week number, is there a way I could use the above DAX around the week number?

 

I'm attaching the pbix file, - link for google drive

https://drive.google.com/file/d/1PYx1PixlCeAh9t_9xpCILgEwLF-0lzed/view?usp=sharing

 

this is how the chart looks currently, when i select Customer A in slicer. 

gav1991_0-1695489277340.png

 

I'm looking to chart to look like below (made in excel)

gav1991_2-1695489888052.png

 

can you help please. much appricated

 

Hi @gav1991 ,

 

Please try below code to create a [Acutal %] measure.

Actual % =
CALCULATE (
    DIVIDE (
        SUM ( 'Order'[Orders placed ≤ 1 Day] ),
        SUM ( 'Order'[Total No of Orders placed] )
    ),
    ALLEXCEPT ( 'Order', 'Order'[Customer] )
)

Result is as below.

vrzhoumsft_0-1695709023934.png

 

Best Regards,
Rico Zhou

 

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

thanks @v-rzhou-msft it worked much appriciated.

123abc
Community Champion
Community Champion

ok i try to solve this and will ans you soon.

123abc
Community Champion
Community Champion

To create a dynamic total for the total orders placed YTD based on a slicer selection, you can use the following DAX measure:

 

Dynamic Total Orders YTD =
VAR SelectedCustomers = VALUES('Order'[Customer])
RETURN
CALCULATE(
SUM('Order'[Total No of Orders]),
FILTER(
ALL('Order'),
'Order'[Customer] IN SelectedCustomers
&& 'Order'[Date] <= MAX('Order'[Date])
)
)

 

Here's how this measure works:

  1. We use the VALUES function to get the list of selected customers from the slicer.

  2. Then, we use the CALCULATE function to calculate the sum of 'Total No of Orders' based on the following conditions:

    • The 'Customer' must be one of the selected customers.
    • The 'Date' must be less than or equal to the maximum 'Date' selected in the slicer.

This measure will dynamically adjust the total orders YTD based on the customer(s) selected in the slicer. When you change the slicer selection, the total will update accordingly.

Make sure you have a 'Date' column in your 'Order' table to track the order date, and ensure that your slicer is connected to the 'Customer' field.

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.

Top Solution Authors