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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
JamesBurke
Helper III
Helper III

Distinct count

Hi All , 

 

I'm looking to make a count of buildings which have been grouped in my database that are performing well based on energy usage last period compared to the current period. 

 

Green Count Consumption = 
VAR _Var = [Total Consumption] - [Last period Cons]
    RETURN
    SWITCH(
        TRUE(),
        _Var > 0 , 0,
        _Var < 0 , 1)

 

This uses a value that compares the current usages against the last period and if it more then zero meaning it has used more it will be counting zero , if it is below one meaning it has used less it will be counting one. 

 

Green Buildings = Calculate(DISTINCTCOUNT(FactUWP[Grouped]) , FILTER('Date',[Green Count Consumption] = 1 ))

 

Not Green Count = Calculate(DISTINCTCOUNT(FactUWP[Grouped]) , FILTER('Date',[Green Count Consumption] = 0 ))

 

however these both return two , Green Buildings should be returning two but they are both returning two for some reason. 

 

Any help would be appericated.

 

1 ACCEPTED SOLUTION
v-pgoloju
Community Support
Community Support

Hi @JamesBurke,

 

Thank you for reaching out to the Microsoft Fabric Forum Community.


The issue with both Green Buildings and Not Green Count returning the same result likely stems from the filtering context and the way you're referencing the Date table in your DAX expressions. To resolve this,

use the ALL('Date') function to remove slicers and filters on the Date table. Ensure proper relationships between the FactUWP and Date tables.


If the issue still persists, please feel free to share more details with Sample data and expected output so that we can further investigate and help resolve it.

If you find this response helpful, please consider marking it as the accepted solution and giving it a thumbs-up to support others in the community.

 

Thank you & regards,
Prasanna Kumar

 

View solution in original post

5 REPLIES 5
v-pgoloju
Community Support
Community Support

Hi @JamesBurke,

 

Just a gentle reminder — has your issue been resolved? If so, we’d be grateful if you could mark the solution that worked as Accepted Solution, or feel free to share your own if you found a different fix.

This not only closes the loop on your query but also helps others in the community solve similar issues faster.

Thank you for your time and feedback!

 

Best,

Prasanna Kumar

v-pgoloju
Community Support
Community Support

Hi @JamesBurke,

 

We wanted to kindly check in to see if everything is working as expected after trying the suggested solution. If there’s anything else we can assist with, please don’t hesitate to ask.

If the issue is resolved, we’d appreciate it if you could mark the helpful reply as Accepted Solution — it helps others who might face a similar issue.

 

Warm regards,

Prasanna Kumar

v-pgoloju
Community Support
Community Support

Hi @JamesBurke,

 

Just following up to see if the solution provided was helpful in resolving your issue. Please feel free to let us know if you need any further assistance.

If the response addressed your query, kindly mark it as Accepted Solution and click Yes if you found it helpful — this will benefit others in the community as well.

 

Best regards,

Prasanna Kumar

v-pgoloju
Community Support
Community Support

Hi @JamesBurke,

 

Thank you for reaching out to the Microsoft Fabric Forum Community.


The issue with both Green Buildings and Not Green Count returning the same result likely stems from the filtering context and the way you're referencing the Date table in your DAX expressions. To resolve this,

use the ALL('Date') function to remove slicers and filters on the Date table. Ensure proper relationships between the FactUWP and Date tables.


If the issue still persists, please feel free to share more details with Sample data and expected output so that we can further investigate and help resolve it.

If you find this response helpful, please consider marking it as the accepted solution and giving it a thumbs-up to support others in the community.

 

Thank you & regards,
Prasanna Kumar

 

lbendlin
Super User
Super User

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...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI 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.

Top Solution Authors
Top Kudoed Authors