how to VLOOKUP a measure result in DAX Power BI - filter

i have Excel Dashboard like this
i want to replicate this in PBI but the result is not the same
in my PBI measure, the Total SKU is
Total SKU = CALCULATE( DISTINCTCOUNT(CSDPVSXML[ProductId]),
ALL('DT Active'), NOT( ISBLANK(CSDPVSXML[ProductId])))
Total SKU 2 = CALCULATE( DISTINCTCOUNT(CSDPVSXML[ProductId]), NOT( ISBLANK(CSDPVSXML[ProductId])))
Total SKU XML 2 using the same DAX script as Total SKU, is there a way to achieve the same result as the excel version, since i cant vlookup in PBI into DAX result, lookup function in PBI only lokup into predefined table, not the result of a measure
thank you in advanced

LookUP is working only with a table, not with a visual. Looking through your question, I assume that you just need to exclude distributor value from filtering.
Try this code:
Total SKU 2 =
CALCULATE(
[Total SKU]
,ALL(tblName[DISTRIBUTOR])
)
new measure
Total SKU 2 =
CALCULATE(
[Total SKU]
,CSDPVSXML[AreaOfPricing]=SELECTEDVALUE(Customer Hierarky[Format Level 3])
,ALL(tblName[DISTRIBUTOR])
)

Related

Calculate the sum grouped by 2 other columns

Please I really need your help on this, Hello,
I need to create a measure using DAX that has the sum of the qty, I should take the max date of the table that is between two other dates (Date Slicer) based on the column name, For example, if the selected date of the slicer is between 24/6/2020 and 20/3/2021, I need to calculate the total (sum of the qty of each name 'column' where it's date is the max date that is less then the max selected date
So as you can see in the figure the total should be 50+129+3(For that selected date)
Quantity =
VAR _maxdate =
MAX ( 'Date Table'[Date] )
RETURN
SUM ( CALCULATE([Qty], 'Fact Table'[Date] <= _maxdate )
The CALCULATE function in DAX is very powerful. Essentially, you can pass filter criteria into it to create aggregations. In this case, it sounds like you want to sum [Qty] when the date is < the max date.
Since your table visuals aren't automatically updating, you also may not be implementing a date table correctly.

DAX formula to get total number of sales in a Calculated Column at a lookup table

I have received answers to my last question. Thanks to all. Now I have another query. I have a lookup table, called Products and a transaction table, called Sales. The relationship between them is one to many. I want to make a Calculated Column at Product to get the total number of sales for each product. I tried to apply Calculate function as solution.
Product [total number of sales] =
Countrows ( Filter (Product, Calculate (Sum( Sales [SalesAmount])))).
I expected products in each row in Product table shall filter the sum of sales amount and generate a virtual table with all the entries related to a particular product. And finally, Countrows shall count the number of entries. But on the contrary, it resulted with same number in each row.
I am just a beginner in DAX. I tried to solve it depending on context transition concept. But my guess was wrong. Please help me out. Thank you in advance.
Use RELATEDTABLE:
If you just want the number of entries in the Sales table per product:
=
COUNTROWS(
RELATEDTABLE( Sales )
)
If you want the total sales per product:
=
SUMX(
RELATEDTABLE( Sales ),
Sales[SalesAmount]
)

creating a static measure to get values in power bi dax

I have the below two tables in power bi as below
based on the above two tables I want to create a matrix visual that should look like the image below "Output Matrix":
I also have a slicer for a month, based on the month column from Table 1, what I want is in the output matrix visual the "Total Users" should remain constant value when we change the month and the rest of the columns values change based on the month selected in the slicer.
Create the following 3 measures:
Measure 1
Active Users = DISTINCTCOUNT( Table1[user_id] ) + 0
Measure 2
Total Users = COUNT( Table2[user_id] ) + 0
Measure 3
Active Users % = DIVIDE( [Active Users], [Total Users], 0 )
Then create a Matrix Visual and drag the Manager column and the 3 measures.
This is the final output:

TOPN DAX function not working. The formula is returning all the rows and not TOP 3

My goal is to create measure to get top 3 customer Names and there respective sales.
I am using the below measure to bring top 3 names along with there sales. The below measure is returning all the rows. I fail to understand why this is happening and why filtering is not happening for top 3 customers
topN = calculate(sum(Sale[Total Excluding Tax]),
TOPN(3,
values(Sale[Employee Name]),
calculate(sum(Sale[Total Excluding Tax]))
)
)
Sale[Employee Name] is calculated column and is coming from another table Employee by using Employee Name = RELATED(Employee[Employee])
The DAX is working properly and grabbing top 3 records. Order/sorting is important. You need to order your results.
Create a calculate column [Total Excluding Tax] to sum up the Total excluding tax. Then use that column in a measure; try something like:
Top Sales = TOPN ( 3, ALLSELECTED( 'Sale' ), [Total Excluding Tax]), desc)

how to I define measurement filter from other table in tabular

I am trying to make measure that gets sum of amt column where versiontype column = ative how do I write dax formula for that measure?
So let's say your fact table is called Sales. It has a Sales Amount called Amt. The table is linked to a Version table with a VersionType field that includes a value of "Active".
You could create a new measure for Active Sales as follows:
ActiveSales :=
CALCULATE (
SUM ( Sales[Amt] ),
'Version'[VersionType] = "Active"
)

Resources