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
chrisyan_manalu
Helper II
Helper II

How to count total red flag and green flag

Hi guys,

 

I am looking for some support with some DAX that I am struggling right now.  I have built a matrix visual as displayed below.

 

chrisyan_manalu_0-1646756366073.png

 

chrisyan_manalu_1-1646757037845.png

 

I have data like this and I want to count how many red flag and green flag in one row with multi period and column.

The result supposed to be there are 2 green colour and there are 9 red colour. 

 

From the table I have included the following DAX.

DurationFlag =
VAR Result = SUM(FactVehicleCheckList[Duration])

RETURN
IF(ISBLANK(Result),-1,1)
 

How to make dax or something to make result like that in power bi ?

 

Can anyone advise me on how to achieve this.

 

Thanks

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Num red flags = COUNTROWS( FILTER(
ADDCOLUMNS( SUMMARIZE( 'Date', 'Date'[Year], 'Date'[Week Number]), "@val", [Duration] ),
[@val] = -1
) )

View solution in original post

3 REPLIES 3
johnt75
Super User
Super User

Num red flags = COUNTROWS( FILTER(
ADDCOLUMNS( SUMMARIZE( 'Date', 'Date'[Year], 'Date'[Week Number]), "@val", [Duration] ),
[@val] = -1
) )

Hi John

 

Thank you for your response. 

 

I tried and it works. 

 

But I'm still struggling about this case because while I'm uncheck all the filter, the red flag is blank. How to make dax if there is no filter, the red flag has the value which is 11 from the example above.

 

Thank you.

Hi @chrisyan_manalu ,

What do you mean by "uncheck all the filter"? Could you please provide some sample data for the fields applied to the matrix visual? Are the fields under the Columns option in the screenshot below from the date dimension table? And is [Duration] a measure? If so, could you please provide the formula for it? Also, please provide some special exammples of the logic for calculating the number of red and green flags (with or without filtering). Thank you.

yingyinr_0-1646992589084.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.