Making DAX calculated table respond to filters on other table - powerbi

I have a DAX table "Sumtable" that calculates the the number of rows in "Maintable" for two cases: (1) all rows in Maintable and (2) the subset of rows where Cat = "A".
Sumtable = {
("Full set", COUNTROWS(Maintable)),
("Subset", COUNTROWS(FILTER(Maintable, Maintable[Cat] = "A")))
}
I want to viz Sumtable and make it respond to filter settings on Maintable. For example when I select Maintable[Sex] = "Male" the totals in Sumtable should reflect that. What is the right way to accomplish this?

For example when I select Maintable[Sex] = "Male" the totals in Sumtable should reflect that.
Just make this two measures instead of a calculated table.
If you want these measures to appear under Sometable, you can create a one-row, one-hidden-column table with two measures, instead of two calculated columns.
And when you hide all the non-measure columns on a table it becomes a "Measure Table" with a differentiated icon.

Solved it with this: analytics-tuts.com/bar-chart-using-measures-in-power-bi

Related

DAX Multiple filters across multiple columns to produce new table

I am using Power BI and I have a table with multiple Columns and Rows that I want to filter with DAX. I want to filter across two columns based on their string value to produce a new table showing the complete row of data that fit both criteria.
For example (I know this is wrong) I want to write something like:
Measure = FILTER('Table 1', [Column1] = "Red" && [Column2] = "Blue")
....Then show a new table of rows containing their full range of data but only those rows that fit both Red and Blue criteria.
Please help.

How do I use an IF THEN function in Power BI over multiple queries?

I am trying to filter an average amount (wage) from one query through a column (gender; 0 = male, 1 = female) belonging to different query.
So, I want put the different averages (query 1) for both genders (query 2) into one card or bar chart visualization.
Can I do this using DAX? Or do I need to merge the queries somehow?
Thank you!
Assuming you mean Tables vs Queries. If you have a relationship between the table with the Gender and a table with the averages, then you just need to include the gender column and the average column in your results.

Filter values based on other column in Power BI

In Power BI I'm trying to combine and get the unique values of pages in a new table. I need to filter one of the columns, based on a value of another column in that same table. So i want to do something like
FILTER(VALUES('Table1'[URL]), 'Table1'[Correct] = "Yes"
But it's not working, because I can only filter based on calculations, not columns.
The complete line that I have now and is working is:
All pages = FILTER(
DISTINCT(UNION(VALUES('Table1'[URL]),VALUES(Table2[Complete URL]),
VALUES('Table3'[URLs]))), [URL] <> BLANK())
How can I add a filter to one of those tables, based on another column of that table?
You can just replace FILTER with CALCULATETABLE:
CALCULATETABLE(VALUES('Table'[URL]), 'Table'[Correct] = "Yes")
If you need to count the values, just wrap it into COUNTROWS:
Measure = COUNTROWS( CALCULATETABLE(VALUES('Table'[URL]), 'Table'[Correct] = "Yes"))

Power BI - Filter table using slicer to match within concatenated column

I've looked all over and can't find a way to do this.
In the table, I have all postcodes throughout the UK and a calculated column that concatenates from another table the products' that have been purchased in that location.
I need to filter the table to hide rows where the value selected in the slicer is in the concatenated column. I think this needs to be a measure and have tried using CONTAINSSTRING but nothing seems to be working.
Latest measure that I have tried is:
=IF(CONTAINSSTRING([Concatenated Values],[Selected Slicer Value]),"Hide","Show")
Does anyone have any ideas?
Example tables and expected results:
You can link the "another table" (the one with the products (not concatenated) per area) to the Area table.
Just change the filter option to: cross-filter direction: both
Then you can use it in your slicer.
Follow these below steps to achieve your requirement.
Let-
Your Slicer Table name: Table1
Your Details table name: Table2
Step-1: Create this following measure in Table2
show_hide_this_row =
FIND(
SELECTEDVALUE(Table1[products]),
MIN(Table2[products]),
,
0
)
Step-2: Add visual level filter using measure "show_hide_this_row" as below-
The output will be as below-
This functionality only works perfect when single selection is enabled in your slicer.

Create table comparing Two Queries with identical fields/field names

I would like to create a table to compare Month To Date (MTD) Vs YTD Sales data metrics
I am using two queries:
1st query = YTD Sales data (Two fields: Sales and Quotes)
2nd query = MTD Sales Data (Two Fields: Sales and Quotes).
Each query has the same field names, just different data
I would like to output a table like the following
How to I create the above table? At the moment I can only create a table like the following:
The latter 1x4 table only works if I appropriately name the fields. But definitely isn’t what I want, because with enough fields, the table could go on forever.
Any help would be appreciated
In the query editor, create a label column for each table that labels what they are and then append the two tables together so you get something like this:
Then you can create a matrix visual with the Label column in the Columns field and the Sales and Quantity columns in the Values area.
Make sure you've switched "Show on Rows" to "On" under the Format > Values section of the Visualizations pane.