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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
MNGoodyear
Frequent Visitor

Creating a measure dynamically based on a slicer value

I have a set of sales data and this data is summarised by account , year and volume

 

I can create a measure to calculate my 22 sales volume  "22 Sales Volume"

I then want to have an additional measure showing the sales volume for another year based on the slicer value the user selects  - "Selected Year Volume"

I would then like to create another measure which calculates the difference between 22 and the value for the selected year giving a gap analysis between the sales for 22 and the total for the selected year - "22 Sales Volume" - "Selected Year Volume"

 

For example if i select year 20 then it would look like below

 

i have tried using the hasonefilter command but cannot get it to sum the qty for that year basius the selcted value

         
accountyearsales   22selected year 20gap
a22100  a100300-200
a21200  b0900-900
a20300      
a19500      
a18600      
b220      
b21500      
b20900      
b19500      
b18600      
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @MNGoodyear ,

 

You need a seperate year table for the sales of the selected year. Here's the solution.

Raw data is as follows which you provided.

vstephenmsft_0-1680767378796.png

1.Create a table using dax. There's no relationship between tables.

vstephenmsft_1-1680767414685.png

2.Create a measure for the sales of the selected year from the year table.

selected year =
CALCULATE (
    SUM ( 'Table'[sales] ),
    FILTER (
        ALL ( 'Table' ),
        [account] = MAX ( 'Table'[account] )
            && [year] = SELECTEDVALUE ( 'Year'[year] )
    )
)

And the gap measure is below.

gap = SUM('Table'[sales])-[selected year]

3.I made arrows indicating the source of the slicer field and which value was generated. 

11.png

You can download my attachment for more details.

 

                                                                                                                                                         

Best Regards,

Stephen Tao

 

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

1 REPLY 1
Anonymous
Not applicable

Hi @MNGoodyear ,

 

You need a seperate year table for the sales of the selected year. Here's the solution.

Raw data is as follows which you provided.

vstephenmsft_0-1680767378796.png

1.Create a table using dax. There's no relationship between tables.

vstephenmsft_1-1680767414685.png

2.Create a measure for the sales of the selected year from the year table.

selected year =
CALCULATE (
    SUM ( 'Table'[sales] ),
    FILTER (
        ALL ( 'Table' ),
        [account] = MAX ( 'Table'[account] )
            && [year] = SELECTEDVALUE ( 'Year'[year] )
    )
)

And the gap measure is below.

gap = SUM('Table'[sales])-[selected year]

3.I made arrows indicating the source of the slicer field and which value was generated. 

11.png

You can download my attachment for more details.

 

                                                                                                                                                         

Best Regards,

Stephen Tao

 

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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors