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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Mike35
Frequent Visitor

Measure to determine a variance between two other measures

Hi all,

 

Hoping someone can help. I have two sets of data which I have imported into PowerBI, both with corresponding measures created to calculate a score percentage. Effectively - the number of "FC" results divided by the number of total results. I then have a slicer that determines date selection, a second slicer that determines the type (Phone or Email), and a final slicer which allows the user to select the area (A, B, C or D) to give a score percentage based on the area and the date selection, or overall if no selection made.

 

One of the requirements posed it the user wants to compare the outcome of data set 1, and data set 2 to understand the variance of the score percentages. In theory, the result of data set 1 for a given date and area should be roughly the same as that in data set 2. If the score for the date/area selection in data set 1 is greater or less than 10% difference of that in data set 2, we're looking to have a visualisation that calls this out, reading "Match" or "Mismatch".

 

A secondary requirement on another page, is to have the same as the above but built into the calculate the "type" as well, so for example if the slicer reads 01/02/2025, the area slicer is selected to "B", is there a measure that can calculate the variance of score of "Phone" between the two data sets, and likewise the same for "Email"

 

Data set examples-

 

Set 1:

Mike35_0-1740062572024.png 

Set 2:

Mike35_1-1740062605187.png

 

Thanks

 

3 REPLIES 3
lbendlin
Super User
Super User


You cannot measure a measure directly. Either materialize it first, or create a separate measure that implements the entire business logic.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Anonymous
Not applicable

Thanks for the reply from lbendlin , please allow me to add some more information:
Hi  @Mike35 ,

 

Here are the steps you can follow๏ผš

1. Create a table containing the sets to be sliced in Tables 1 and 2.

Slicer_Table =
VAR _table1 =
    SUMMARIZE ( 'Table1', [Date], [Type], [Area] )
VAR _table2 =
    SUMMARIZE ( 'Table2', [Date], [Type], [Area] )
RETURN
    DISTINCT ( UNION ( _table1, _table2 ) )

vyangliumsft_0-1740120724903.png

2. Create measure.

Measure1 =
VAR _selectdate =
    SELECTCOLUMNS ( 'Slicer_Table', "date", [Date] )
VAR _selecttype =
    SELECTCOLUMNS ( 'Slicer_Table', "type", [Type] )
VAR _selectarea =
    SELECTCOLUMNS ( 'Slicer_Table', "area", [Area] )
VAR _sumall =
    SUMX ( ALL ( 'Table2' ), [Value] )
VAR _value1 =
    SUMX (
        FILTER (
            ALL ( 'Table1' ),
            'Table1'[Date]
                IN _selectdate
                    && 'Table1'[Type]
                    IN _selecttype
                        && 'Table1'[Area] IN _selectarea
        ),
        [Value]
    )
RETURN
    IF (
        HASONEVALUE ( 'Slicer_Table'[Date] ) = FALSE ()
            && HASONEVALUE ( 'Slicer_Table'[Type] ) = FALSE ()
            && HASONEVALUE ( 'Slicer_Table'[Area] ) = FALSE (),
        _sumall,
        DIVIDE ( _value1, _sumall )
    )
Measure2 =
VAR _selectdate =
    SELECTCOLUMNS ( 'Slicer_Table', "date", [Date] )
VAR _selecttype =
    SELECTCOLUMNS ( 'Slicer_Table', "type", [Type] )
VAR _selectarea =
    SELECTCOLUMNS ( 'Slicer_Table', "area", [Area] )
VAR _sumall =
    SUMX ( ALL ( 'Table2' ), [Value] )
VAR _value2 =
    SUMX (
        FILTER (
            ALL ( 'Table2' ),
            'Table2'[Date]
                IN _selectdate
                    && 'Table2'[Type]
                    IN _selecttype
                        && 'Table2'[Area] IN _selectarea
        ),
        [Value]
    )
RETURN
    IF (
        HASONEVALUE ( 'Slicer_Table'[Date] ) = FALSE ()
            && HASONEVALUE ( 'Slicer_Table'[Type] ) = FALSE ()
            && HASONEVALUE ( 'Slicer_Table'[Area] ) = FALSE (),
        _sumall,
        DIVIDE ( _value2, _sumall )
    )
Test =
IF(
    DIVIDE([Measure1]- [Measure2],[Measure2]) >=0.1,"Mismatch","Match")

3. Result:

vyangliumsft_1-1740120724906.png

If you want to calculate the variance, you can use the following dax:

VARX.S function (DAX) - DAX | Microsoft Learn

VARX.P function (DAX) - DAX | Microsoft Learn

 

Best Regards,

Liu Yang

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

Mike35
Frequent Visitor

Hi @Anonymous - thank you for your efforts but I am confused on the output of the DAX you have demonstrated. I do not understand how the scores have been calculated because there does not appear to be any Score columing in the table. For example if I manually filter my data to 3rd Feb, Area B & Email as per the final output, set 1 should show no score because there were no entries that match this criteria, whereas set 2 would show 100% as there were 2 x FC entries in the set.

 

@lbendlin Thanks for your pointers and the links to help provide sample data. I have included both data sets here. To hopefully keep it more simple, I have already added filters to the measures quoted below to include Area & Type in the division calculation.

Internal data set:

DateAreaTypeScore
01/02/2025APhoneFC
01/02/2025BEmailFC
01/02/2025APhoneNC
01/02/2025CEmailFC
01/02/2025APhoneFC
01/02/2025BEmailNC
01/02/2025DPhoneFC
02/02/2025AEmailFC
02/02/2025BPhoneFC


Internal Score measure:

 

 

Internal Compliance = 
DIVIDE(
    CALCULATE(
        COUNTROWS('Internal_Phone_Email_Test'),
        'Internal_Phone_Email_Test'[Area] = "B", 'Internal_Phone_Email_Test'[Type] = "Email", 'Internal_Phone_Email_Test'[Score] = "FC" || 'Internal_Phone_Email_Test'[Score] = "CID"
    ),
    CALCULATE(
        COUNTROWS('Internal_Phone_Email_Test'),
        'Internal_Phone_Email_Test'[Area] = "B", 'Internal_Phone_Email_Test'[Type] = "Email"
    )
)

 

 

 

External data set:

DateAreaTypeScore
01/02/2025BPhoneFC
01/02/2025CEmailFC
01/02/2025DPhoneFC
01/02/2025AEmailFC
01/02/2025APhoneFC
01/02/2025BEmailFC
01/02/2025DPhoneFC
01/02/2025CEmailFC
01/02/2025CPhoneNC

 

External compliance measure:

 

 

External Compliance = 
DIVIDE(
    CALCULATE(
        COUNTROWS('External_Phone_Email'),
        'External_Phone_Email'[Area] = "B", 'External_Phone_Email'[Type] = "Email", 'External_Phone_Email'[Score] = "FC" || 'External_Phone_Email'[Score] = "CID"
    ),
    CALCULATE(
        COUNTROWS('External_Phone_Email'),
        'External_Phone_Email'[Area] = "B", 'External_Phone_Email'[Type] = "Email"    
    )
    )

 

 


Desired output will effectively be controlled by a slicer for date with the card in the centre showing as Match if both measures are within 10% variance, "Mismatch" if >10% variance.

Mike35_0-1740498694444.png


Thanks 

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

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!

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.

Users online (27)