Tableau- if statement with aggregation - if-statement

I want to calculate the percentage of "class = high" per store
Thanks
Example

sum(int([class]=“high”)) / count([class])

Related

DAX how to do SUMMARIZECOLUMNS() and only return where =COUNT>2

I need to write a dax function where I can achieve the below visual in a measure. I actually need to get the count of it:
as you can see, I need to group by transcation date, registeration and quantity, and then select * where count(quantity) > 1.
I couldn't go further than this:
number of issues on same day = =
COUNTROWS(FILTER(SUMMARIZECOLUMNS('Transaction'[Transaction
Date],'Transaction'[REGISTRATION],"CountQuantity",[Number of
Ref (CM)]),[Number of Ref (CM)] > 2))
the visual shows the whole record but I need to show the count of such info as a measure in a card. so it will show 1 in my count for the below card. thanks
If we have a measure and we need to use it as part of filter then use a variable.
TestCard = calculate (countrows('Table'), Filter(ALL('Table'), var __count = [CountMeasure] return __count>2 ))
I managed to fix it myself:
=COUNTROWS(FILTER(SUMMARIZECOLUMNS('Transaction'[Transaction
Date],'Transaction'[REGISTRATION],"CountQuantity",[Number of Ref (CM)]),
[Number of Ref (CM)] > 1))

Sum of Calculated Column

I have calculated column Importance_Weight of which I need to create measure that sum questions for related line number.
Importance_Weight = (ColumnX * Average(ColumnY) )/100
Calculated column values for each question is correct as below but when aggrigated by line number the sum is wrong as blow
I used following measure to calculate sum of questions (q) i.e. L1
LT_WeightPerQuestion:=SUMX(DimQuestion, AVERAGE(Survey[Importance_Weight]))
Thanks in advance.
Use measure as below
LT_WeightPerQuestion = SUM(Survey[Importance_Weight])

Simplify google sheet formula "SUM / INDEX / MATCH"

I am trying to use google sheet to create a roster formula, to sum up the duty hour per week using INDEX/MATCH/SUM.
But it's too long, is there any way to simplify the formula?
Also, I realize "MATCH" cannot recognize blank cell (N20), can that be fixed too?
=IFERROR(SUM(INDEX($O$12:$O$20,MATCH(D17,$N$12:$N$20,0)),INDEX($O$12:$O$20,MATCH(E17,$N$12:$N$20,0)),INDEX($O$12:$O$20,AND(F17,$N$12:$N$20,0)),INDEX($O$12:$O$20,MATCH(G17,$N$12:$N$20,0)),INDEX($O$12:$O$20,MATCH(H17,$N$12:$N$20,0)),INDEX($O$12:$O$20,MATCH(I17,$N$12:$N$20,0)),INDEX($O$12:$O$20,MATCH(J17,$N$12:$N$20,0))),"Err")
try:
=ARRAYFORMULA(MMULT(IFERROR(REGEXREPLACE(UPPER(B6:H14), "^"&TEXTJOIN("$|^", 1, L1:L10)&"$",
VLOOKUP(REGEXEXTRACT(UPPER(B6:H14), "^"&TEXTJOIN("$|^", 1, L1:L10)&"$"), L1:M10, 2*
SIGN(ROW(A6:A14)), 0)&""), UPPER(B6:H14))*1, TRANSPOSE(COLUMN(B:H))^0))
Franco, since your post says your end goal is to "sum up the duty hour per week," I take that to mean all you need in the end is a single number.
Try this (which will give you total hours for your block that runs B6:H22:
=ArrayFormula(SUM(COUNTIF(B6:H22,$L$1:$L$8)*$M$1:$M$8))
If you need to see the breakdown per code, you can use this:
=ArrayFormula({$L$1:$L$8,COUNTIF(B6:H22,$L$1:$L$8)*$M$1:$M$8})
Just replace "B6:H22" with the reference of each calendar block to get the sum or the breakdown for other weeks.

SUMIF Array Formula with "GREATER THAN"

I know this may work:
=ArrayFormula(sum(SUMIF(D2:D9&F2:F9,J2:J3&H2,E2:E9)))
But I don't know how to find any solution for this
=ArrayFormula(sum(SUMIF(D2:D9&F2:F9,J2:J3&(">"&H2),E2:E9)))
Basically, I want to SUMIF with multiple criterias with array formula. But I can't find a way with criteria that greater than something
this is the sample case: https://docs.google.com/spreadsheets/d/1lyPSurAudZOAn2HHGPaKcgmwso46f3K4dVYA6dwlDjM/edit#gid=0
the case is about summing the quantity given from each activity, given some range of date.
array formula is needed since I want the list of activity to be flexibly added, without me having to edit the formula.
as far as I know, sumifs cant be used because sumifs doesn't work with array formula
try:
=ARRAYFORMULA(SUM(IF((F2:F>H2)*(REGEXMATCH(D2:D,
TEXTJOIN("|", 1, J2:J))), E2:E, )))
or try:
=SUM(FILTER(E2:E, REGEXMATCH(D2:D, TEXTJOIN("|", 1, J:J)), F2:F>H2))
Some alternative:
sumif and vlookup==>
=arrayformula(sumif((1-isna(vlookup(D2:D9,J2:J3,1)))*F2:F9,">" & H2,E2:E9))
sum if and vlookup:
=arrayformula(sum(if((1-isna(vlookup(D2:D9,J2:J3,1)))*F2:F9>H2,E2:E9,0)))
Sum and vlookup:
=arrayformula(sum((iferror(vlookup(D2:D9,J2:J3,1),"")=D2:D9)*(F2:F9>H2)*E2:E9))

How to limit a max value in a cell?

I am setting up a new spreadsheet in google spreadsheets and I need to set a max value because it can surpass that number.
I am currently using this formula -> =SUMPRODUCT(D17:D33) and that sum can be more than 50, and if that's true, I want to limit to 50.
Any tips?
Please try:
=min(50;sumproduct(D17:D33))
try something simple like:
=IF(SUMPRODUCT(D17:D33)>50; 50; SUMPRODUCT(D17:D33))