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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Nath_nath
Frequent Visitor

Creating a distinct count measure based on a total

Dear fellow PBI enthusiasts,

I am having more than expected trouble finishing this measure. I would like to calculate the unique number of cases where total case amount (irregards used slicers) is above a certain number. In fact I would like to make a measure which could create the most right (blue) column. 

Nath_nath_0-1650976279695.png

 


Note: simply using below formula will not work as I need total per case. Below formula would resemble the result in the most right yellow column.

 

Count = Calculate ( distinctcount(fact'[cases]) , fact'[minutes] > 100)

 

Also this should work in a power bi dataset using a start model where multiple other dimensions are used. If anyone would be so kind to help, just assume that for each of the dimensionfields seeing in above example, in reality a seperate dimension table exists.


Thank you so much!

 

 

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@Nath_nath,

 

Try these measures. The variable vCaseTotals is a virtual table that contains the total minutes for each case, which is then filtered for "> 100". Then, the virtual table of cases > 100 is used as a CALCULATE filter.

 

Total Minutes = SUM ('fact'[Minutes] )
Distinct Count Minutes > 100 = 
VAR vCaseTotals =
    ADDCOLUMNS (
        VALUES ( 'fact'[Case] ),
        "@Minutes", CALCULATE ( [Total Minutes], ALLEXCEPT ( 'fact', 'fact'[Case] ) )
    )
VAR vCasesOver100 =
    FILTER ( vCaseTotals, [@Minutes] > 100 )
VAR vResult =
    CALCULATE ( DISTINCTCOUNT ( 'fact'[Case] ), vCasesOver100 )
RETURN
    vResult

 

DataInsights_0-1651070944938.png

 





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

Proud to be a Super User!




View solution in original post

1 REPLY 1
DataInsights
Super User
Super User

@Nath_nath,

 

Try these measures. The variable vCaseTotals is a virtual table that contains the total minutes for each case, which is then filtered for "> 100". Then, the virtual table of cases > 100 is used as a CALCULATE filter.

 

Total Minutes = SUM ('fact'[Minutes] )
Distinct Count Minutes > 100 = 
VAR vCaseTotals =
    ADDCOLUMNS (
        VALUES ( 'fact'[Case] ),
        "@Minutes", CALCULATE ( [Total Minutes], ALLEXCEPT ( 'fact', 'fact'[Case] ) )
    )
VAR vCasesOver100 =
    FILTER ( vCaseTotals, [@Minutes] > 100 )
VAR vResult =
    CALCULATE ( DISTINCTCOUNT ( 'fact'[Case] ), vCasesOver100 )
RETURN
    vResult

 

DataInsights_0-1651070944938.png

 





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

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.