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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Nick_2510
Helper I
Helper I

count all negative numbers

I want to count all negative numbers by rows and in total...but it doesn't work in total

M =
SUMX ( VALUES ( Data[Name] ), IF ( [diff_AvSal_bal] < -1, 1, 0))

Nick_2510_0-1652265697498.png

 

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

@Nick_2510 
Please try

Count of -ve =
SUMX (
    CROSSJOIN ( VALUES ( 'Date'[Date] ), VALUES ( Data[Name] ) ),
    IF ( [diff_AvSal_bal] < -1, 1, 0 )
)

View solution in original post

20 REPLIES 20
tamerj1
Super User
Super User

@Nick_2510 
Please try

Count of -ve =
SUMX (
    CROSSJOIN ( VALUES ( 'Date'[Date] ), VALUES ( Data[Name] ) ),
    IF ( [diff_AvSal_bal] < -1, 1, 0 )
)

Thx a lot! It works!


But now I need to add one option in IF constraction...

switch off name if name in a period - data for this in another table with colomns (Name, Start_period, End_Period)

 

Count of -ve =

SUMX (
CROSSJOIN ( VALUES ('Календарь'[Date]), VALUES ( Data[Name] ) ),
IF ( [diff_AvSal_bal] >0 OR 'Календарь'[Date] IN DATESBETWEEN('Sheet1'[Start_per], 'Sheet1'[End_per], 0, 1)
)


SUMX (
CROSSJOIN ( VALUES ('Календарь'[Date]), VALUES ( Data[Name] ), 'delist'),
IF ( [diff_AvSal_bal] >= 0 || ('Календарь'[Date] >= 'delist'[Start_per] && 'Календарь'[Date] <= 'delist'[End_per]), 0, 1 )
)

How to connect Name in first table and in Second (Start_per, End_per)...now it puts 0 to every name which is in that period(

@Nick_2510 
Now its different. I need to see sample data of the two tables and the relationships between the three tables.

@tamerj1 

delist

Nick_2510_0-1652431590301.png

 

data

Nick_2510_1-1652431611374.png

 

relationships

Nick_2510_2-1652431666775.png

 

other 2 tables are handbooks....Glossary - names of products and specifications, and Celendar(Date)

@Nick_2510 
In your table visual please use the [Name] column from the 'delist' dimention table and not from the fact 'Data' table. Then you may try

Count of -ve =
SUMX (
    CROSSJOIN ( VALUES ( 'Календарь'[Date] ), delist ),
    IF (
        [diff_AvSal_bal] > 0
            || 'Календарь'[Date] IN CALENDAR ( delist[Start_per], delist[End_per] ),
        0,
        1
    )
)

But in table 'delist' are not all names...the main table is Data...all calculations and visualizations are made due to it...and Name I take from Glossary...

Can you share a sample file?

HI @tamerj1 

Nick_2510_0-1652535489832.png

 

It should be 0, because this names on this dates are  in delist table (second condition)....(((

@Nick_2510 

Maybe you mean "AND" not "OR". Please try replace || with &&

@tamerj1 
No, I mean put 0 if name on this day is in delist OR diff_AvSal_bal > 0...but it takes 1...I tried to reverse conditions and got error

 

OOS =
SUMX (
CROSSJOIN ( VALUES ('Календарь'[Date]), VALUES ( Glossary[Name] ) ),
IF ('Календарь'[Date] IN
CALENDAR (
CALCULATE ( SELECTEDVALUE ( delist[Start_per] ) ),
CALCULATE ( SELECTEDVALUE ( delist[End_per] ) )
||
[diff_AvSal_bal] > 0
),
0, 1 )
)
 
Calendar start date or end date cannot be null
 

 

Hi @Nick_2510 

The 'delist' table is not there in the file!

Arul
Super User
Super User

@Nick_2510 ,

try this,

Negative val = SUMX(Negative,IF(Negative[Diff]<0,1,0))

Arul_0-1652266664627.png

 





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

Proud to be a Super User!


LinkedIn


This formula is not for measures

tamerj1
Super User
Super User

Hi @Nick_2510 

Please try

Count of -ve =
SUMX ( VALUES ( Data[Name] ), CALCULATE ( IF ( [diff_AvSal_bal] < -1, 1, 0 ) ) )

Hi! The same result(

Nick_2510_0-1652266615240.png

 

@Nick_2510 
Do you have other active filters of the page or on the visual? any slicers? Any other table or other column invloved?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.

Top Solution Authors