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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Agent47
Helper I
Helper I

Different measures returning same value

I have written the following measures for corresponding TAbleau Calculated functions 
----------------------------
{ INCLUDE [Risk] : COUNTD([Ra Code])} (Tableau)
----
Measure_RA_SUM =
    CALCULATE(
        DISTINCTCOUNT('Risk Assesment'[Ra_Code]),
        ALLEXCEPT('Hazard', 'Hazard'[Risk])
    )
---------------
  { INCLUDE [Control Type] : COUNTD([Ra Code])} (Tableau)
----
Measure_RA_SUM2 =
    CALCULATE(
        DISTINCTCOUNT('Risk Assesment'[Ra_Code]),
        ALLEXCEPT('Consequences', 'Consequences'[Control_Type])
    )
----------------------------------
{ INCLUDE[RA Type],[Vessel]  : COUNTD([Ra Code])}(Tableau)
-----
Measure_RA_SUM3 =
    CALCULATE(
        DISTINCTCOUNT('Risk Assesment'[Ra_Code]),
        ALLEXCEPT('Risk Assesment', 'Risk Assesment'[Ra_Type], 'Risk Assesment'[Vessel])
    )
----------------------------------------
COUNTD([Ra Code]) (Tableau)
--
Measure_RA_Code_Cnt = DISTINCTCOUNT('Risk Assesment'[Ra_Code])
---------------------------
RA_code is present in Risk Assessment table and Risk is present in Hazard table . Those two tables are connected by a primary key Ra_Master_Id


But they all return same value 

Agent47_0-1731386424244.png

 

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @Agent47 -  It is returning the same value because the ALLEXCEPT function might not be filtering the way you expect, likely due to the relationships in your data model.

create measure RA_SUM as below:

 

Measure_RA_SUM =
CALCULATE(
DISTINCTCOUNT('Risk Assesment'[Ra_Code]),
TREATAS(VALUES('Hazard'[Risk]), 'Risk Assesment'[Risk])
)

 

another measure sum2 

Measure_RA_SUM2 =
CALCULATE(
DISTINCTCOUNT('Risk Assesment'[Ra_Code]),
TREATAS(VALUES('Consequences'[Control_Type]), 'Risk Assesment'[Control_Type])
)

 

sum3 measure:

Measure_RA_SUM3 =
CALCULATE(
DISTINCTCOUNT('Risk Assesment'[Ra_Code]),
REMOVEFILTERS('Risk Assesment'[RA_Type]),
REMOVEFILTERS('Risk Assesment'[Vessel]),
VALUES('Risk Assesment'[RA_Type]),
VALUES('Risk Assesment'[Vessel])
)

 

Measure_RA_Code_Cnt (No Change)

Measure_RA_Code_Cnt = DISTINCTCOUNT('Risk Assesment'[Ra_Code])

 

THorughly check that the relationships are correctly set up, and verify that Ra_Master_Id is properly connecting Hazard and Risk Assesment.


you can also use the Performance Analyzer or DAX Studio to see how filters are propagating across tables to understand any unexpected filtering.

 

Hope this helps.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

5 REPLIES 5
rajendraongole1
Super User
Super User

Hi @Agent47 -  It is returning the same value because the ALLEXCEPT function might not be filtering the way you expect, likely due to the relationships in your data model.

create measure RA_SUM as below:

 

Measure_RA_SUM =
CALCULATE(
DISTINCTCOUNT('Risk Assesment'[Ra_Code]),
TREATAS(VALUES('Hazard'[Risk]), 'Risk Assesment'[Risk])
)

 

another measure sum2 

Measure_RA_SUM2 =
CALCULATE(
DISTINCTCOUNT('Risk Assesment'[Ra_Code]),
TREATAS(VALUES('Consequences'[Control_Type]), 'Risk Assesment'[Control_Type])
)

 

sum3 measure:

Measure_RA_SUM3 =
CALCULATE(
DISTINCTCOUNT('Risk Assesment'[Ra_Code]),
REMOVEFILTERS('Risk Assesment'[RA_Type]),
REMOVEFILTERS('Risk Assesment'[Vessel]),
VALUES('Risk Assesment'[RA_Type]),
VALUES('Risk Assesment'[Vessel])
)

 

Measure_RA_Code_Cnt (No Change)

Measure_RA_Code_Cnt = DISTINCTCOUNT('Risk Assesment'[Ra_Code])

 

THorughly check that the relationships are correctly set up, and verify that Ra_Master_Id is properly connecting Hazard and Risk Assesment.


you can also use the Performance Analyzer or DAX Studio to see how filters are propagating across tables to understand any unexpected filtering.

 

Hope this helps.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hi Rajendra , now the values are indeed unique ,thanks for that. 

Agent47_0-1731410361471.png

but the expected values 
are 

Agent47_1-1731411389158.png

 


I changed Measure_RA_SUM =
CALCULATE(
DISTINCTCOUNT('Risk Assesment'[Ra_Code]),
TREATAS(VALUES('Hazard'[Risk]), 'Risk Assesment'[Risk])
)  
with 

Measure_RA_SUM =
CALCULATE(
DISTINCTCOUNT('Risk Assesment'[Ra_Code]),
TREATAS(VALUES('Hazard'[Risk]), 'Hazard'[Risk])

)
as Risk resides in table 'Hazard' .
similarly 
Measure_RA_SUM2 =
CALCULATE(
DISTINCTCOUNT('Risk Assesment'[Ra_Code]),
TREATAS(VALUES('Consequences'[Control_Type]), 'Risk Assesment'[Control_Type])
)
was replaced by 
Measure_RA_SUM2 =
CALCULATE(
DISTINCTCOUNT('Risk Assesment'[Ra_Code]),
TREATAS(VALUES('Consequences'[Control_Type]), 'Consequences'[Control_Type])

----------
Agent47_2-1731415772384.png

cross filter direction = both in all cases.
Can you please suggest any alternative ? Thanks again .




 

Many thanks @rajendraongole1 

Agent47
Helper I
Helper I

@SamWiseOwl  @Kedar_Pande  @lbendlin  please contribute if you can

Agent47
Helper I
Helper I

@rajendraongole1  please help

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors