Forum Discussion
SQL to DAX conversion
- 8 years ago
Try this New Table from Modelling Tab
New Table = SUMMARIZE ( C, C[Start Time], C[End Time], "Count", CALCULATE ( COUNT ( D[Operating value] ), FILTER ( D, D[Operating value] <= 5 && D[Process Time] >= C[Start Time] && D[Process Time] <= C[End Time] ) ) ) - 8 years ago
Another way
New Table2 = CALCULATETABLE ( SUMMARIZE ( C, C[Start Time], C[End Time], "Count", CALCULATE ( COUNT ( D[Operating value] ), FILTER ( D, D[Process Time] >= C[Start Time] && D[Process Time] <= C[End Time] ) ) ), D[Operating value] <= 5 )
Hello mwadhwani,
Instead of converting the query, you can just use it Power BI.
Power BI supports native queries to SQL, so you can use SQL to query data.
Here is how where to put your query:
Hi Birdjo,
Thank you Birdjo for reply.
I have imported my data into Power BI. Also I have my source as Excel.So I cannot use above option.
So I need DAX query
Thanks
- Zubair_Muhammad8 years agoCommunity Champion
Try this New Table from Modelling Tab
New Table = SUMMARIZE ( C, C[Start Time], C[End Time], "Count", CALCULATE ( COUNT ( D[Operating value] ), FILTER ( D, D[Operating value] <= 5 && D[Process Time] >= C[Start Time] && D[Process Time] <= C[End Time] ) ) )- Zubair_Muhammad8 years agoCommunity Champion
Another way
New Table2 = CALCULATETABLE ( SUMMARIZE ( C, C[Start Time], C[End Time], "Count", CALCULATE ( COUNT ( D[Operating value] ), FILTER ( D, D[Process Time] >= C[Start Time] && D[Process Time] <= C[End Time] ) ) ), D[Operating value] <= 5 ) - mwadhwani8 years agoKudo Kingpin
Thank You Zubair_Muhammad!!
- mwadhwani8 years agoKudo Kingpin
Hello Zubair_Muhammad,
I tried your query and it took very close to my solution.Only thing I am not getting in my output is Count of Operating Value.
All values in this column are NULL. I tried to debug, When I run subset of your code:
New Table =
SUMMARIZE (
C,
C[Start Time] ,
C[End Time],
"NoOfEvents", COUNT (D[OperatingValue] )
)
Still I am getting Null values for "NoOfEvents". I checked my data I also have data for it.
I am not able to debug further. Can you please suggest where my code is going wrong.Thanks
- Zubair_Muhammad8 years agoCommunity Champion
I believe there in no relationship between C and D.
Thats why the subset code you wrote is retruning zeros
In my code i dad mimiced this relationship using Calculate and Filter