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
Anonymous
Not applicable

Using field parameters to get a count of applicable measures by a field

Hallo guys,

 

I want to calculate how many times my “Tips ”measures are applicable by my customers.

I have the following dataset:

This is the fact table:

Customers

Profit

Cost

Bank balance

A

10.000

5.000

20.000

B

11.000

3.000

30.000

C

15.000

1.000

100.000

D

4.000

2.000

10.000

E

2.000

200

5.000


this is the dim table:

Customers

Name

A

John

B

Jane

C

Joe

D

Jennie

E

Janneth

 

Here are some examples of my “Tips” measures:

Tip - profit = if(sum(Customer data[Profit]) >= 10.000, “Congratulation with 10K plus profit”, blank())

Tip – cost = if(sum(Customer data[Bank balance]) >= 25.000, “Try to reinvest your money”, blank())

I want to create a page where to total amount of tips is visible. So I can select via a Parameter the tip “Tip - Profit” which shows me in a visual the total time this tip is applicable. And in another matrix shows me the customers for which this tip is applicable.


My desired result would be.

Filter on parameter “Tip profit”
visual shows me: 3

Matrix visual shows me:

Customer A
Customer B

Customer C

 

Thank you in advance!

 

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

Hi @Anonymous ,

Please try below steps:

1. create a table and add it to slicer visual
Table:

vbinbinyumsft_0-1663221589753.png

vbinbinyumsft_1-1663221611449.png

2. create below four measure

Tip Cost =
VAR tmp =
    FILTER ( ALL ( 'Fact' ), 'Fact'[Bank balance] >= 25000 )
RETURN
    COUNTROWS ( tmp )
Tip Profit =
VAR tmp =
    FILTER ( ALL ( 'Fact' ), 'Fact'[Profit] >= 10000 )
RETURN
    COUNTROWS ( tmp )
Measure =
VAR cur_tip =
    SELECTEDVALUE ( 'Table'[Tip] )
RETURN
    SWITCH (
        TRUE (),
        cur_tip = "Tip-cost",
            "Filter on parameter:Tip cost" & "
" & "visual shows me: " & [Tip Cost],
        cur_tip = "Tip-profit",
            "Filter on parameter:Tip profit" & "
" & "visual shows me: " & [Tip Profit]
    )
Measure2 =
VAR cur_tip =
    SELECTEDVALUE ( 'Table'[Tip] )
VAR cur_customer =
    SELECTEDVALUE ( 'Fact'[Customers] )
VAR tmp =
    FILTER ( ALL ( 'Fact' ), 'Fact'[Profit] >= 10000 )
VAR tmp1 =
    FILTER ( ALL ( 'Fact' ), 'Fact'[Bank balance] >= 25000 )
RETURN
    SWITCH (
        cur_tip,
        "Tip-profit", IF ( CONTAINS ( tmp, [Customers], cur_customer ), 1, 0 ),
        "Tip-cost", IF ( CONTAINS ( tmp1, [Customers], cur_customer ), 1, 0 )
    )

3. add a card visual with a measure named "Measure"

4. add a table visual visual with "Fact[Customers]" column

5. add the measure named "Measure 2" to table visual filter pane and set it "is 1"

vbinbinyumsft_2-1663221991653.png

 

Now you can see below :

Animation14.gif

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
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
v-binbinyu-msft
Community Support
Community Support

Hi @Anonymous ,

Please try below steps:

1. create a table and add it to slicer visual
Table:

vbinbinyumsft_0-1663221589753.png

vbinbinyumsft_1-1663221611449.png

2. create below four measure

Tip Cost =
VAR tmp =
    FILTER ( ALL ( 'Fact' ), 'Fact'[Bank balance] >= 25000 )
RETURN
    COUNTROWS ( tmp )
Tip Profit =
VAR tmp =
    FILTER ( ALL ( 'Fact' ), 'Fact'[Profit] >= 10000 )
RETURN
    COUNTROWS ( tmp )
Measure =
VAR cur_tip =
    SELECTEDVALUE ( 'Table'[Tip] )
RETURN
    SWITCH (
        TRUE (),
        cur_tip = "Tip-cost",
            "Filter on parameter:Tip cost" & "
" & "visual shows me: " & [Tip Cost],
        cur_tip = "Tip-profit",
            "Filter on parameter:Tip profit" & "
" & "visual shows me: " & [Tip Profit]
    )
Measure2 =
VAR cur_tip =
    SELECTEDVALUE ( 'Table'[Tip] )
VAR cur_customer =
    SELECTEDVALUE ( 'Fact'[Customers] )
VAR tmp =
    FILTER ( ALL ( 'Fact' ), 'Fact'[Profit] >= 10000 )
VAR tmp1 =
    FILTER ( ALL ( 'Fact' ), 'Fact'[Bank balance] >= 25000 )
RETURN
    SWITCH (
        cur_tip,
        "Tip-profit", IF ( CONTAINS ( tmp, [Customers], cur_customer ), 1, 0 ),
        "Tip-cost", IF ( CONTAINS ( tmp1, [Customers], cur_customer ), 1, 0 )
    )

3. add a card visual with a measure named "Measure"

4. add a table visual visual with "Fact[Customers]" column

5. add the measure named "Measure 2" to table visual filter pane and set it "is 1"

vbinbinyumsft_2-1663221991653.png

 

Now you can see below :

Animation14.gif

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
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.