Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi Team,
how to write below sql query in dax expression?
select title, hours from table where title like '%gold%' or title like '%silver%'
we need to find calcualte hours based on gold or silver?
can you please assist?
Thanks
Kunuthuri
Solved! Go to Solution.
Hi @Anonymous,
Please refer to:
Table =
VAR temptab =
FILTER (
ADDCOLUMNS (
Table5,
"Type", IF (
ISERROR ( FIND ( "Gold", Table5[Title] ) ) = FALSE (),
"Gold",
IF (
ISERROR ( FIND ( "Silver", Table5[Title] ) ) = FALSE (),
"Silver",
BLANK ()
)
)
),
[Type] <> BLANK ()
)
RETURN
GROUPBY ( temptab, [Type], "Total Hours", SUMX ( CURRENTGROUP (), [Hours] ) )
Best regards,
Yuliana Gu
@Anonymous As there is no sample data, here is the sample data I assumed...
Now create a "New Column" as below:
TitleNew = SWITCH(TRUE(),
SEARCH("Gold",[Title],1,-1)>0,"Gold",
SEARCH("Silver",[Title],1,-1)>0,"Silver",
"Other")
The table now looks like...
Now create a "New Table" in required format with total hours...
GoldSilverHours = SUMMARIZECOLUMNS(SearchText[TitleNew],"TotalHours",SUM(SearchText[Hours]))
So fiinally, the output looks like...
Hope this helps !!
Proud to be a PBI Community Champion
Thanks for reply
can you please help below requirement .
1. I need to find only Gold and silver records, not others records.
2. Total Hours for(gold and silver) / Hours
Thanks
Kunuthuri
Hi @Anonymous,
Please refer to:
Table =
VAR temptab =
FILTER (
ADDCOLUMNS (
Table5,
"Type", IF (
ISERROR ( FIND ( "Gold", Table5[Title] ) ) = FALSE (),
"Gold",
IF (
ISERROR ( FIND ( "Silver", Table5[Title] ) ) = FALSE (),
"Silver",
BLANK ()
)
)
),
[Type] <> BLANK ()
)
RETURN
GROUPBY ( temptab, [Type], "Total Hours", SUMX ( CURRENTGROUP (), [Hours] ) )
Best regards,
Yuliana Gu
Thanks for reply
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 70 | |
| 45 | |
| 43 | |
| 36 | |
| 23 |
| User | Count |
|---|---|
| 196 | |
| 126 | |
| 106 | |
| 78 | |
| 55 |