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
Justas4478
Post Prodigy
Post Prodigy

Count of a measure

Hi, 
I have this measure:

Shorted = 'Outbound Delivery'[Total Demand] - 'Outbound Delivery'[Total Actual]
It calculates difference between ordered and actual resulting in amount not fufilled.
I am trying to create other measure that counts how many 'Shorted' there are per day.
That is measure I tried:
Shorted times count = COUNTAX('Outbound Delivery','Outbound Delivery'[Shorted])
This is result I got but what I expected to get is in red:
Justas4478_0-1713882596884.png

Let me know if there are any questions.

 

Thanks



1 ACCEPTED SOLUTION

Hi @Justas4478,

I'm using this data set:

_AAndrade_0-1713947821227.png


And this is my measures:

Total Actual = SUM(T_Outbound[Actual]) 

Total Demand = SUM(T_Outbound[Demand]) 

Shorted = [Total Demand] - [Total Actual]

Count Shorted = 
VAR _Table = 
    SUMMARIZE(
         T_Outbound, 
         T_Outbound[Level 2],
         T_Outbound[Date],
         "@Shorted", [Shorted]
    )
VAR _Result =
    COUNTX(
        FILTER(
             _Table,
              [@Shorted] <> 0
        ),
        [@Shorted]
    )
RETURN
  _Result


The output is:

_AAndrade_1-1713947962532.png


I hope this could solve your problem.







Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




View solution in original post

9 REPLIES 9
_AAndrade
Super User
Super User

Try this measure:

CALCULATE(
    COUNT(T_OutboundDelivery[Shorted]),
    T_OutboundDelivery[Shorted] <> 0
)

The final result would be this:

_AAndrade_0-1713883849056.png

 





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




@_AAndrade Hi, I am using measures since it is company controlled live connection model.
That is only thing I am able to create.
This is what I have in 'Outbound Delivery' table.
I created 'Shorted' measure using 'Total Demand' and 'Total Actual' measures.
But there are 'Demand' and 'Actual' hidden columns that would need to be summarised.

Justas4478_0-1713943109401.png

Idealy I would like the solution to work with the measures if possible.

Hi @Justas4478,

I'm using this data set:

_AAndrade_0-1713947821227.png


And this is my measures:

Total Actual = SUM(T_Outbound[Actual]) 

Total Demand = SUM(T_Outbound[Demand]) 

Shorted = [Total Demand] - [Total Actual]

Count Shorted = 
VAR _Table = 
    SUMMARIZE(
         T_Outbound, 
         T_Outbound[Level 2],
         T_Outbound[Date],
         "@Shorted", [Shorted]
    )
VAR _Result =
    COUNTX(
        FILTER(
             _Table,
              [@Shorted] <> 0
        ),
        [@Shorted]
    )
RETURN
  _Result


The output is:

_AAndrade_1-1713947962532.png


I hope this could solve your problem.







Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




@_AAndrade Hi, I have been using solution that you provided.
And it is great, there are only case when shorted qty is 0 it returns rezult blank when I would expect to return 0.
I tried to change  <> to >= in the measure but that only change from this:

Justas4478_1-1714657155435.png 
to this:

Justas4478_0-1714657136255.png

I am not sure which part I need to modify so the 1's that have shorted qty of 0 would return 0.
Thanks

@_AAndrade I think I manage to find the solution I added +0 to this part of the dax.

VAR _Result =
    COUNTX(
        FILTER(
             _Table,
              [@Shorted] <> 0
        ),
        [@Shorted]
    )+0
RETURN
  _Result

Let me know if you think there is better way.
This is the result:

Justas4478_0-1714665364353.png

 


 

Great news.





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




@_AAndrade It looks like it is working without any problems so far.
Thank you for the help.

Great.You're welcome.





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




_AAndrade
Super User
Super User

Hi @Justas4478,


You are using calculated columns, right?





Did I answer your question? Mark my post as a solution! Kudos are welcome.

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.