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

Slicer as Calculator

A somewhat self-referencing question here!

There is a PowerBI cost calculator here. 

damian_bell_0-1614960005252.png

It is a webpage rather than a PowerBi report but I would like to perform the same functions within PBI. 
My use case is obviously different but the key similarity is generating a cost based on varying proportions of a 'whole'. 
In the example above the two sliders can be independently set anywhere along the slicer and that changes the number of Pro, Frequent and Occasional Users. I can set up a simple slicer but how can I get it to simultaneously adjust 3 parameters? 
I can probably get the cost total on the right of the screenshot to work but the slicer setup has me baffled - any help gratefully received!

Thank you

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

Hi @damian_bell 

You could try to build a slicer table as below.

 

Percentage Slicer = GENERATESERIES(0, 1, 0.0001)

 

Build a slicer by between and slicer is as below.

1.png

I build a User table.

1.png

Measure:

 

Percent User = 
VAR _Total_User = 5000
VAR _PercentUser1 =
    MIN ( 'Percentage Slicer'[Percentage Slicer] )
VAR _PercentUser2 =
    MAX ( 'Percentage Slicer'[Percentage Slicer] ) - _PercentUser1
VAR _PercentUser3 =
    1 - MAX ( 'Percentage Slicer'[Percentage Slicer] )
RETURN
    SWITCH (
        TRUE (),
        MAX ( User[User] ) = "User1",
            FORMAT ( _PercentUser1 * _Total_User, "0" ) & "     "
                & FORMAT ( _PercentUser1, "(0.00%)" ),
        MAX ( User[User] ) = "User2",
            FORMAT ( _PercentUser2 * _Total_User, "0" ) & "     "
                & FORMAT ( _PercentUser2, "(0.00%)" ),
        FORMAT ( _PercentUser3 * _Total_User, "0" ) & "     "
            & FORMAT ( _PercentUser3, "(0.00%)" )
    )
TotalPrice = 
VAR _Total_User = 5000
VAR _PercentUser1 =
    MIN ( 'Percentage Slicer'[Percentage Slicer] )
VAR _PercentUser2 =
    MAX ( 'Percentage Slicer'[Percentage Slicer] ) - _PercentUser1
VAR _PercentUser3 =
    1 - MAX ( 'Percentage Slicer'[Percentage Slicer] )
VAR _NumUser1 = _PercentUser1*_Total_User
VAR _NumUser2 = _PercentUser2*_Total_User
VAR _NumUser3 = _PercentUser3*_Total_User
VAR _TotalPrice = _NumUser1*100+_NumUser2*200+_NumUser3*50
RETURN
_TotalPrice

 

Result is as below.

1.png

You can download the pbix file from this link: File

 

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

2 REPLIES 2
damian_bell
Frequent Visitor

This is *exactly* what I needed! Thank you so much, it would have taken me many frustrating hours to get even close to working this out. Now I see your solution I can see that it isn't too complicated but I have learnt a lot as I have played with this today. I am very grateful for your help. Thank you. 

v-rzhou-msft
Community Support
Community Support

Hi @damian_bell 

You could try to build a slicer table as below.

 

Percentage Slicer = GENERATESERIES(0, 1, 0.0001)

 

Build a slicer by between and slicer is as below.

1.png

I build a User table.

1.png

Measure:

 

Percent User = 
VAR _Total_User = 5000
VAR _PercentUser1 =
    MIN ( 'Percentage Slicer'[Percentage Slicer] )
VAR _PercentUser2 =
    MAX ( 'Percentage Slicer'[Percentage Slicer] ) - _PercentUser1
VAR _PercentUser3 =
    1 - MAX ( 'Percentage Slicer'[Percentage Slicer] )
RETURN
    SWITCH (
        TRUE (),
        MAX ( User[User] ) = "User1",
            FORMAT ( _PercentUser1 * _Total_User, "0" ) & "     "
                & FORMAT ( _PercentUser1, "(0.00%)" ),
        MAX ( User[User] ) = "User2",
            FORMAT ( _PercentUser2 * _Total_User, "0" ) & "     "
                & FORMAT ( _PercentUser2, "(0.00%)" ),
        FORMAT ( _PercentUser3 * _Total_User, "0" ) & "     "
            & FORMAT ( _PercentUser3, "(0.00%)" )
    )
TotalPrice = 
VAR _Total_User = 5000
VAR _PercentUser1 =
    MIN ( 'Percentage Slicer'[Percentage Slicer] )
VAR _PercentUser2 =
    MAX ( 'Percentage Slicer'[Percentage Slicer] ) - _PercentUser1
VAR _PercentUser3 =
    1 - MAX ( 'Percentage Slicer'[Percentage Slicer] )
VAR _NumUser1 = _PercentUser1*_Total_User
VAR _NumUser2 = _PercentUser2*_Total_User
VAR _NumUser3 = _PercentUser3*_Total_User
VAR _TotalPrice = _NumUser1*100+_NumUser2*200+_NumUser3*50
RETURN
_TotalPrice

 

Result is as below.

1.png

You can download the pbix file from this link: File

 

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. 

 

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.