Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hello I have an SQL query as follows :
SELECT a.School, SUM(a.Value) AS Value
FROM(
select School,max(Value) AS Value from table
group by FileId,School
) a
group by School
How do I translate this into DAX ?
Solved! Go to Solution.
@AnonymousIt's because measure returns table (just like your SQL query). To return single value change measure:
Measure=var tempTable=ADDCOLUMNS(SUMMARIZE('Table','Table'[FileId],'Table'[School]),"max_value",CALCULATE(MAX('Table'[Value])))
return CALCULATE(SUMX(tempTable,[max_value]))
@Anonymous Try something like this:
Measure=var tempTable=ADDCOLUMNS(SUMMARIZE('Table','Table'[FileId],'Table'[School]),"max_value",CALCULATE(MAX('Table'[Value])))
return ADDCOLUMNS(SUMMARIZE(tempTable,[School]),"sum_value",CALCULATE(SUMX(tempTable,[max_value])))
Hello, I have created a table graph with 2 columns School and the measure you created. I received the following error :
@AnonymousIt's because measure returns table (just like your SQL query). To return single value change measure:
Measure=var tempTable=ADDCOLUMNS(SUMMARIZE('Table','Table'[FileId],'Table'[School]),"max_value",CALCULATE(MAX('Table'[Value])))
return CALCULATE(SUMX(tempTable,[max_value]))
The measure worked perfectly, but can you please show me how to add a WHERE clause in it ?
SELECT a.School, SUM(a.Value) AS Value
FROM(
select School,max(Value) AS Value from table
-- New
WHERE Statut LIKE '%abc%'
--End New
group by FileId,School
) a
group by School
Thanks a lot man you are a life saver
@Anonymous Replace first parameter of SUMMARIZE function ('Table') with FILTER('Table',SEARCH("abc",'Table'[Statut],1,0)) :
Measure=var tempTable=ADDCOLUMNS(SUMMARIZE( FILTER('Table',SEARCH("abc",'Table'[Statut],1,0)),'Table'[FileId],'Table'[School]),"max_value",CALCULATE(MAX('Table'[Value])))
return CALCULATE(SUMX(tempTable,[max_value]))
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 37 | |
| 35 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 74 | |
| 70 | |
| 39 | |
| 35 | |
| 23 |