Forum Discussion
Using two filters with CALCULATE
- 9 years ago
Hi Concat,
Just as what scottsen said, you have to use Measures here not Calculated columns.
By the way, if you want to get the topn records of a table by some conditions such as a specific date as you mentioned, you don't have to use rankx, you can create a table using code below to get top 5 records with filtered date:
Table 2 = TOPN(5, Filter(SheetTable, SheetTable[date] > Date(2016, 7, 1)))
Best Regards
Alex
I feel as if you are (as I like to say) "off in the weeds". :)
I'm hampered by 2 things:
* Your use a horrible terms like "measure" (for a column) and Sheet1/Table1, etc.
* That there is just really really limited number of times that I try to create calculations and push them into a new table.
From your original mail: "I need to produce a table with count of each string value for a given date range" -- how do you specify this "date range"? From the dax you have shown seems like it is simply "everything before today" ?
Think I also need to know the relationships between 'SheetTable' and 'Table'
Also note that you can add aggregate expressions on your Summarize(SheetTable,SheetTable[Column1]), like:
Summarize(SheetTable,SheetTable[Column1], "The Row Count", COUNTROWS(SheetTable))
(Though, you may need to wrap that countrows in a calculate for the same reason as my last post).
You do not need a new table if you replace 'measure' with 'VAR'.
However; Creating a calculation table ensures each step of the code works before you apply;
it also helps organize, and you can cut down on alot of looping code by just calling simple measures like ''SharedCalcTable: [Column1sumOfstuff] + [Column2averageOfStuff].
In Addition; if you have a shared dataset; you do not need to re-write the code, just 'getData' and pull down your Common calculations table. Great for Finance and Quality stuff.
This style of "New Table'' is an attempt to follow Azure Synapse Workbooks, Jupyter Notebooks, GoogleColab; They all use the same 'modular' approach to Table Code. And its GOOD.