Forum Discussion
Anonymous
3 years agoNot applicable
Display table contents for particular column value with conditions
Hello all, I have a problem that I've been trying to figure out. I have a table with three columns (sample data shown below): I am trying to create a calculated table from the above ...
- 3 years ago
Hi Midmurali,
My approach would be to do this at the Power Query level.
Using your own sample Data, open Power Query.
Steps below:
- Reference your data table.
In the left hand query section, right click on your table and select reference per the below. Best to use reference not duplicate so you aren't running any prior transformations twice.
Referencing will create a duplicate of your current sample data that we can run the next transformations on.
I have renamed the reference table in my example to "Summary Table". - Step two - Pivot Columns.
In the transformations tab, select "Pivot Column", then use Date as your Values Column and Count (ALL) as your aggregate value function. - Add the three new columns together using a new column per below.
- Delete the A, B and C columns as unnecessary.
- Filter the "All Operations" Column to only include items with the number 3.
This will give you the result you want but without the dates. - To add the dates back in, we can hit "Close and Apply" and head out of Power Query.
Jump into your model view and set up the relationship between your old table and the new summary table. The join should be on ProductID to ProductID with a many to 1 relationship. - And thats it!
Now if you go into the report view, select the table visual and use the Date Field from your original data table, with the ProductID field from your summary table. Open the visual filters and set ProductID to "Is Not Blank" And you get the result below!
I am hoping this way isn't too involved. There may be an easier way that others can find.
I have uploaded the PBIX file here if you want to have a look!
https://www.dropbox.com/s/lpjuhuro5f4i7wf/Midmurali%20-%20Sample%20Solution.pbix?dl=0Good luck!
- Reference your data table.
- 3 years ago
Try a measure along the lines of:
All A B C = VAR _List = {"A", "B", "C"} VAR _ListRows = COUNTROWS(_list) VAR _ABC = CALCULATETABLE(VALUES(fTable[Operation]), ALLEXCEPT(fTable, fTable[ProductID])) VAR _Int = COUNTROWS(INTERSECT(_ABC, _List)) RETURN IF(_Int = _ListRows, 1)(If you need this calculation by date, include the date field in the ALLEXCEPT expression in VAR _ABC)
- 3 years ago
Hi Anonymous - Pls find attached the PBIX link for reference. Please mark accepted if this fixed your requirement. Many Thanks