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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Justas4478
Responsive Resident
Responsive Resident

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.