How to show not filtered data - powerbi

I am new to power bi, and this question might be a common question and already answered, but I didn't find any precise solution.
I have two tables; "Dates" and "Accounts".
Dates table has only one column: "Date"(date type). It has only date value, which is day based.
Accounts table has two columns; Name(text type) and CreatedDate(date dypttype).
In my power bi model, there is a relationship(many to one, single, active) between Dates.Date and Accounts.CreatedDate columns.
I want to show account names that except the filtered ones. For example, my Accounts table look like this:
Name
CreatedDate
A Company
2020-01-01
B Company
2020-12-15
C Company
2021-03-03
D Company
2019-05-27
I have a slicer and use Dates.Date as It's field.
When I filtered my data as last 1 year (2020-08-18 - 2021-08-18), I want to show the data which is not filtered. I want to see this:
Name
CreatedDate
A Company
2020-01-01
D Company
2019-05-27
How to show the data which is not filtered?

You can create a filter Measure like following
_filter:=
SWITCH (
TRUE (),
/* t1 = what is value selected ?*/
CONVERT ( SELECTEDVALUE ( 'Calendar'[Calendar_Date] ), INTEGER ) = BLANK ()
/* t2=what is the max CreatedDate value visble in the filter context*/
/*if t1 and t2 both blank then return -999 else return t1-t2 which should be 0*/
&& CONVERT ( MAX ( tbl[CreatedDate] ), INTEGER ) = BLANK (), -999,
CONVERT ( SELECTEDVALUE ( 'Calendar'[Calendar_Date] ), INTEGER )
- CONVERT ( MAX ( tbl[CreatedDate] ), INTEGER )
)

Related

Unexpected result of measure from filtering table with dynamic criteria in Power BI

I have a table called DW_XYZ:
Year
Month
Type
Value
2021
1
A
10
2021
1
B
12
2021
2
A
20
*no data for type B in Month=2
I would like to create a measure that stores data that I already filtered by last month of data stored in DW_XYZ with dax formula:
CALCULATE(
SUM(DW_XYZ[Value]),
FILTER(DW_XYZ,DW_XYZ[Month]=
CALCULATE(MAX(DW_XYZ[Month]),
FILTER(DW_XYZ,DW_XYZ[Year]=
MAX(DW_XYZ[Year]))) && DW_XYZ[Year]=MAX(DW_XYZ[Year]))
From the measure, I create 2 card visuals to display data of Type A and Type B each. 1st visual to display type A, so I drag the measure, and also drag column Type to 'visual filter' and manually select 'A', and do the same for 2nd visual (type B).
For type A, the card display expected value (of type A and Month=2).
But for type B, the card display unexpected value (of type B and Month=1), it should be type B and Month=2 which is blank/zero. **btw, would be highly appreciated if the formula including blank value-handling to be zero (0) instead of blank.
Try
MyMeasure =
VAR MaxYear =
CALCULATE ( MAX ( DW_XYZ[Year] ), ALL ( DW_XYZ[Type] ) )
VAR MaxMonth =
CALCULATE ( MAX ( DW_XYZ[Month] ), ALL ( DW_XYZ[Type] ) )
RETURN
0
+ CALCULATE (
SUM ( DW_XYZ[Value] ),
FILTER ( DW_XYZ, DW_XYZ[Year] = MaxYear && DW_XYZ[Month] = MaxMonth )
)
A crucial difference between the above and your attempt is the inclusion of ALL applied to the Type column as a filter for CALCULATE when determining the latest year and month. Without this, the external filter you are applying to the visual will force the evaluation to consider that Type only when determining those values.

Group by date, Distinct and ignore other filters - Power BI

I have the dataset where the values in the col 'value' are repeated per month and id, e.g. for 1/1/2020 and id 1, the value is 0.5, for 2/1/2020, the value is 2, etc. The dataset has other columns which are to be used as filters for other calculations.
What will be the measure to get:
so that even when I use filters from the table, e.g. filter1, the value remains grouped by date ONLY?
I've tried with sumx and max; sum and value but nothing gives a result and calculation still reacts on other filters.
When i spoke abount ALL i had in mind this kind of solution:
WithoutExternalFilter =
CALCULATE (
VAR __dist =
ADDCOLUMNS (
SUMMARIZE ( Te, Te[Date], Te[ID] ),
"val", CALCULATE ( MAX ( Te[value] ) )
)
RETURN
SUMX ( __dist, [val] ),
ALL ( Te[filter1] )
)
WHEN we put some filter, value for "2020-08-01" is still 1.1:

When we sum column value in power bi table, if value is null or blank then how to show it as 0 in power?

In my Power BI Dashboard table after creating dashboard if some row values are empty then how to make it as 0 instead of Null or Blank value
After done R & D i found an solution, I have created measure and populated in Dashboard page instead of directly assigning the column value. The measure which i created is
Expenses Value =
IF (
CALCULATE ( SUM ( Expenses[Amount] ) ) = BLANK (),
0,
CALCULATE ( SUM ( Expenses[Amount] ) )
)
If date field is missing then
Date =
VAR MCON = FORMAT(TODAY(),“dd/M/yyyy")
RETURN TF(
SELECTEDVALUE('New Registration'[$1]) = BLANK(),
MCON,
SELECTEDVALUE('New Registration'[$1])
)
Result

TopN, Grouping, Show Others at the bottom POWERBI-DAX

I have the following formula which creates the table in the screenshot below on the left (names of actual tables are different - also it combines 2 separate tables in one) -
Top 11 Jun =
IF (
[Type Rank Jun] <= 11,
[Total Jun],
IF (
HASONEVALUE ( Partners[partner_group] ),
IF (
VALUES ( Partners[partner_group] ) = "Others",
SUMX (
FILTER ( ALL ( Partners[partner_group] ), [Type Rank Jun] > 11 ),
[Total Jun]
)
)
)
)
Now i'm stuck on how to combine the "Null" and "Others" under "Others" and put "Others" at the bottom.i can combine the "Null" & "Others" at each table level, i'm just not sure how.
The DAX solution:
To get the Other and blank (at least that is how I read your null) together, you can create a new column on the table (is easiest).
newProducts = IF(fruits[product] = BLANK(); "Other";fruits[product])
A better solution is to replace your blanks (or NULL) in the Query language:
Go to: Edit Query:
Select your table and the product column and press on the bar the "Replace values"
Do the replace and save and close the editor.
Last step
It is not relevant in which order you have the rows in the table because you can control this in the visual self.
Below example:
As you can see, I filtered other out, this is not needed when you want to count them in your top N.
If you want to show all four, we need to make a new Table:
Tabel =
var Top3 = TOPN(3;FILTER(fruits;fruits[product] <> "Other") ;fruits[July Avail])
var prioTop3 = ADDCOLUMNS(Top3;"Order"; CALCULATE(COUNTROWS(fruits);FILTER(Top3; fruits[July Avail] <= EARLIER(fruits[July Avail]))))
var Other = ADDCOLUMNS(GROUPBY(FILTER(fruits;fruits[product] = "Other");fruits[product];"June Avail"; SUMX(CURRENTGROUP();fruits[June Avail]); "July Avail"; SUMX(CURRENTGROUP();fruits[July Avail]));"Order";0)
return UNION(prioTop3; Other)
Result:

DAX to lookup date in ValidFrom column

I have two (2) tables
Tablename: X
ID Name ValidFrom Property
A-----Test1-----01.01.2010---------30
A-----Test1-----01.01.2015---------60
B-----Test1-----01.01.1900---------30
B-----Test2-----01.01.2018---------60
Tablename: Y
ID Date
A---01.01.2010
A---01.02.2010
A---01.03.2015
A---01.04.2015
Ideally, I would like to add calculated columns to Table Y which looks up ID and date with ID and ValidFrom from Table X. In this example, row#1 in Table X would be the returning row of data for all dates >= 01.01.2010 and dates < 01.01.2015. The resulting outcome would be like this:
Tablename: Y (new)
ID Date Name Property
A---01.01.2010----Test1------30
A---01.02.2010----Test1------30
A---01.03.2015----Test1------60
A---01.04.2015----Test1------60
Any help would be greatly appreciated
It's not clear how the Name column is generated, but here's how you can get the Property column once you have the Name column in table Y:
Property =
VAR LastValid =
CALCULATE (
MAX ( X[ValidFrom] ),
FILTER (
ALL ( X[ValidFrom] ),
X[ValidFrom] <= EARLIER ( Y[Date] )
)
)
RETURN
LOOKUPVALUE (
X[Property],
X[ID], Y[ID],
X[Name], Y[Name],
X[ValidFrom], LastValid
)
The LastValid variable finds the latest date that is less than or equal to the date in the current row. Then you use that along with the ID and Name to look up the Property from table X.
Taking in the last formula and applying the LOOKUPVALUE to the ID and ValidFrom as you refers, I tried successfully the next approach:
Name =
VAR LastValid =
CALCULATE(MAX(X[ValidFrom]);
FILTER (
ALL(X[ValidFrom] );
X[ValidFrom] <= EARLIER (Y[Date] )
)
)
RETURN
LOOKUPVALUE (
X[Name];
X[ID]; Y[ID];
X[ValidFrom]; LastValid
)