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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
novotnajk
Resolver I
Resolver I

IF / AND Measure using Values from Two Tables to Display a Measure Value

Hi!

 

I have another tough formula to build (at least I think it's tough)!

 

I created two tables in my model called, "Plan Spend Category", and "Plan Spend Parameter" - These two tables, identify the following:

 

Plan Spend Category

Medical = Medical Plan

Rx = Pharmacy Plan

Total = Both Medical and Pharmacy

 

Plan Spend Parameter

Amt Paid = Total Paid by the Company

PEPM = Per Employee Per Month

PEPY = Per Employee Per Year

PMPM = Per Member Per Month

PMPY = Per Member Per Year

 

Untitled.png

 

In my model I have several measures:

Medical PEPM

Medical PMPM

Rx PEPM

Rx PMPM

Total PEPM

Total PMPM

Medical PEPY

Medical PMPY

Rx PEPY

Rx PMPY

Total PEPY

Total PMPY

 

Each of these measures is a formula to display a dollar value.

 

My issue is, how do I create a formula that says, if a filtered value from Plan Spend Category and Plan Spend Parameter is "X", show "X Measure (i.e., if Plan Spend Category is Medical and Plan Spend Parameter is PEPM, then show value for Medical PEPM, etc., etc..  If no filter is selected, the default is Total Amt Paid.

 

Help!!??!??!!?!?

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

Hi @novotnajk 

I think you want to show different  results (measures) by select slicer.

Firstly you need to build two slicer table.

Category Table:

1.png

Parameter Table:

2.png

Due to I don't know your value, I build a sample measure for you. I use number to replace the measures you use.

 

Measure = 
VAR _Selcategory =
    SELECTEDVALUE ( 'Plan Spend Category'[Category] )
VAR _Selparameter =
    SELECTEDVALUE ( 'Plan Spend Parameter'[Parameter] )
VAR _Medical_PEPM = 1
VAR _Medical_PMPM = 2
VAR _Rx_PEPM = 3
VAR _Rx_PMPM = 4
VAR _Total_Amt_Paid = 5
RETURN
    IF (
        ISFILTERED ( 'Plan Spend Category'[Category] )
            && ISFILTERED ( 'Plan Spend Parameter'[Parameter] ),
        IF (
            AND ( _Selcategory = "Medical", _Selparameter = "PEPM" ),
            _Medical_PEPM,
            IF (
                AND ( _Selcategory = "Medical", _Selparameter = "PMPM" ),
                _Medical_PMPM,
                IF ( AND ( _Selcategory = "Rx", _Selparameter = "PEPM" ), _Rx_PEPM, _Rx_PMPM )
            )
        ),
        _Total_Amt_Paid
    )

 

Result is as below. 

As default it will show the result of _Total_Amt_Paid.

3.png

If I select Medical and PEPM in Slicers, it will show the result of _Medical_PEPM.

4.png

You can add more measures by var and update this measure like I show you above.

 

You can download the pbix file from this link: IF / AND Measure using Values from Two Tables to Display a Measure Value

 

If this reply still couldn't help you solve your problem, please show me more details about your data model.

You can give me a sample table like you are dealing with, show me a screenshot of your data model or you can provide me with your pbix file by your Onedrive for business.

 

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

6 REPLIES 6
v-rzhou-msft
Community Support
Community Support

Hi @novotnajk 

I think you want to show different  results (measures) by select slicer.

Firstly you need to build two slicer table.

Category Table:

1.png

Parameter Table:

2.png

Due to I don't know your value, I build a sample measure for you. I use number to replace the measures you use.

 

Measure = 
VAR _Selcategory =
    SELECTEDVALUE ( 'Plan Spend Category'[Category] )
VAR _Selparameter =
    SELECTEDVALUE ( 'Plan Spend Parameter'[Parameter] )
VAR _Medical_PEPM = 1
VAR _Medical_PMPM = 2
VAR _Rx_PEPM = 3
VAR _Rx_PMPM = 4
VAR _Total_Amt_Paid = 5
RETURN
    IF (
        ISFILTERED ( 'Plan Spend Category'[Category] )
            && ISFILTERED ( 'Plan Spend Parameter'[Parameter] ),
        IF (
            AND ( _Selcategory = "Medical", _Selparameter = "PEPM" ),
            _Medical_PEPM,
            IF (
                AND ( _Selcategory = "Medical", _Selparameter = "PMPM" ),
                _Medical_PMPM,
                IF ( AND ( _Selcategory = "Rx", _Selparameter = "PEPM" ), _Rx_PEPM, _Rx_PMPM )
            )
        ),
        _Total_Amt_Paid
    )

 

Result is as below. 

As default it will show the result of _Total_Amt_Paid.

3.png

If I select Medical and PEPM in Slicers, it will show the result of _Medical_PEPM.

4.png

You can add more measures by var and update this measure like I show you above.

 

You can download the pbix file from this link: IF / AND Measure using Values from Two Tables to Display a Measure Value

 

If this reply still couldn't help you solve your problem, please show me more details about your data model.

You can give me a sample table like you are dealing with, show me a screenshot of your data model or you can provide me with your pbix file by your Onedrive for business.

 

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. 

 

vanessafvg
Super User
Super User

Hi are you able to provide some dummy data?




If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Thank you! This worked!  I just replaced the values of 1, 2, etc. with the other measures I created. 

Thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Hi!

 

Sure.  Here are the actual table names and data:

 

Table 1:  'MeasureGrouper[Plan Spend Category] (values of Medical, Rx, Total)

Table 2:  'MeasureGrouper[Plan Spend Paratmenter] (values of PEPM, PEPY, PMPM, PMPY, Amt Paid]

 

Measures

To get PEPY:

Medical PEPY = CALCULATE(DIVIDE('Medical[Plan Spend]),(Members)

Medical PEPM = CALCULATE(DIVIDE(Medical PEPY), (Months) ---- note, that the months measure takes a look at the min/max dates of a reporting period field and creates a number, which is always equal to 12.

 

Rx and Total measures look exactly the same, except you replace Medical with Rx or with Total.

 

 

Hi Vanessa, Are you still able to assist? @vanessafvg 

hi thanks for that measures code, are you able to provide some data with this please?




If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.