Trying to get list of Venues with respect to Suppliers - powerbi

Hi guys so i am trying to build a report where i have to show new customers this month compared to last month. I am able to calculate new customers fine but i have to show them in a Matrix in Power Bi. This is the Code i am using
New Customers This Month =
VAR ThisMonth =
SELECTEDVALUE( DailyReport[DateCreated].[MonthNo])
VAR ThisYEAR =
SELECTEDVALUE(DailyReport[DateCreated].[Year])
VAR SelectedSupplier =
SELECTEDVALUE(DailyReport[SupplierName])
VAR LastMonth = ThisMonth - 1
VAR CustomersThisMonth =
DISTINCT(
SELECTCOLUMNS(
FILTER( ALL( DailyReport ), DailyReport[DateCreated].[MonthNo] = ThisMonth && DailyReport[DateCreated].[Year] = ThisYEAR && DailyReport[SupplierName] = SelectedSupplier),
"C1", DailyReport[VenueName]
)
)
VAR CustomersLastMonth =
DISTINCT(
SELECTCOLUMNS(
FILTER( ALL( DailyReport ), DailyReport[DateCreated].[MonthNo] = LastMonth && DailyReport[DateCreated].[Year] = ThisYEAR && DailyReport[SupplierName] = SelectedSupplier),
"C1", DailyReport[VenueName]
)
)
VAR T1 =
EXCEPT(CustomersThisMonth, CustomersLastMonth )
RETURN
CONCATENATEX( T1, [C1], ", " )
I am getting result like this, two columns one for supplier and one for new venues this month
getting result like this
But expected result should be like this, you know like a list
expected result
i think it may be causing due to how i am concatening it in the last line in code
and please let me know if you need any more information

Related

Compare Selected quarter to last quarter in DAX, even when i select Q1 it should compare with last year's Q4

Hi i am working on a solution in DAX where i have to find customers not ordered in current Quarter compared to its last quarter, i am able to compare Q2, Q3 and Q4 but when i select Q1 i get no value. if i select it should compare with Q4 of last year
how this can be achieved?
Thanks
this was my original question
get new customers compared to last month in dax power bi
with a little bit of tinkering i am here now
Customers Not ordered This Quarter =
VAR ThisQuarter =
SELECTEDVALUE( DailyReport[DateCreated].[QuarterNo])
VAR ThisYEAR =
SELECTEDVALUE(DailyReport[DateCreated].[Year])
VAR SelectedSupplier =
SELECTEDVALUE(DailyReport[SupplierName])
VAR LastQuarter = ThisQuarter - 1
VAR CustomersThisQuarter =
DISTINCT(
SELECTCOLUMNS(
FILTER( ALL( DailyReport ), DailyReport[DateCreated].[QuarterNo] = ThisQuarter && DailyReport[SupplierName] = SelectedSupplier && DailyReport[DateCreated].[Year] = ThisYEAR),
"C1", DailyReport[VenueName]
)
)
VAR CustomersLastQuarter =
DISTINCT(
SELECTCOLUMNS(
FILTER( ALL( DailyReport ), DailyReport[DateCreated].[QuarterNo] = LastQuarter && DailyReport[SupplierName] = SelectedSupplier && DailyReport[DateCreated].[Year] = ThisYEAR),
"C1", DailyReport[VenueName]
)
)
VAR T1 =
EXCEPT(CustomersLastQuarter, CustomersThisQuarter )
RETURN
CONCATENATEX( T1, [C1], UNICHAR(10), [C1], ASC)
it should compare with the last year's Q4 when i select Q1 in current year
You really need a date table. I have written the code below blind but it should work.
Customers Not ordered This Quarter =
VAR ThisQuarter =
SELECTEDVALUE( DailyReport[DateCreated].[QuarterNo])
VAR ThisYEAR =
SELECTEDVALUE(DailyReport[DateCreated].[Year])
VAR SelectedSupplier =
SELECTEDVALUE(DailyReport[SupplierName])
VAR LastQuarter = IF(ThisQuarter = 1,4,ThisQuarter - 1)
VAR LastYear = IF(ThisQuarter = 1,ThisYEAR -1,ThisYEAR)
VAR CustomersThisQuarter =
DISTINCT(
SELECTCOLUMNS(
FILTER( ALL( DailyReport ), DailyReport[DateCreated].[QuarterNo] = ThisQuarter && DailyReport[SupplierName] = SelectedSupplier && DailyReport[DateCreated].[Year] = ThisYEAR),
"C1", DailyReport[VenueName]
)
)
VAR CustomersLastQuarter =
DISTINCT(
SELECTCOLUMNS(
FILTER( ALL( DailyReport ), DailyReport[DateCreated].[QuarterNo] = LastQuarter && DailyReport[SupplierName] = SelectedSupplier && DailyReport[DateCreated].[Year] = LastYEAR),
"C1", DailyReport[VenueName]
)
)
VAR T1 =
EXCEPT(CustomersLastQuarter, CustomersThisQuarter )
RETURN
CONCATENATEX( T1, [C1], UNICHAR(10), [C1], ASC)

grand total empty in table

I've the following pbix https://1drv.ms/u/s!Amd7BXzYs7AVlXPjuP0CfblYyc5K?e=kNnEiN
I've the following measure 
Measure2 = var _1=max(MaxPropre[Nb]) +0
var _min = minx(ALLSELECTED('Date Filter'), 'date Filter'[Date]) var ax = maxx(ALLSELECTED('MaxPropre'), 'MaxPropre'[Date])
var _max = maxx(ALLSELECTED('date Filter'), 'date Filter'[Date]) VAR dt =SELECTEDVALUE ( 'DimDate'[date] )
return
CALCULATE(if((max('DimDate'[Date]) <_min || max('DimDate'[Date]) >_max ) , BLANK(), if(ax >=dt,[const],0)))
 
why I'm not getting the grand total please?
You can add another measure like:
Measure3 = IF(HASONEFILTER('DimDate'[date]),[Measure2],SUMX(VALUES('DimDate'[date]),[Measure2]))
...and use it in your table.
This site explains what you're dealing with fairly well.

more filter apply on the DAX

Good Day!
Request
The following is my raw data, with some conditions applied to check which columns need to be counted.
Example:
Row 1, direction is export, department code is not starting with 'D',
will count all 6 columns (ETD, ATD,ETA, ATA, Estimated Delivey,
Actual Delivery) , and only 5 have been filled in, so get 83 as the
percentage.
Row 2, direction is export, department code starting
with 'D', will only count 4 columns (ETA, ATA,Estimated Delivery
and Actual Delivery), and only 2 has been filled in, so get 50%.
What I have now:
I have a code but it only shows all columns and which column has been filled, and I would like some help in calculating the conditions as stated above.
DAX: (calculate not blank)
Count =
SUMX(
ADDCOLUMNS(
RawData,
"Count",
var tab = {RawData[ETD],RawData[ATD],RawData[ETA],RawData[ATA],RawData[Estimated Delivery],RawData[Actual Delivery]}
var result =
COUNTROWS(
FILTER(
tab,
[Value]<>BLANK()))
return
IF(
ISBLANK(result),
0,
result
) ),[Count])
DAX: Calculate blank
Count =
SUMX(
ADDCOLUMNS(
RawData,
"Count",
var tab = {RawData[ETD],RawData[ATD],RawData[ETA],RawData[ATA],RawData[Estimated Delivery],RawData[Actual Delivery]}
var result =
COUNTROWS(
FILTER(
tab,
[Value]=BLANK()))
return
IF(
ISBLANK(result),
0,
result
) ),[Count])
Any help will be greatly appreciated.
Attached here with my pbix: https://drive.google.com/file/d/1KIROrAzNEp710JEfxMfiZLzvTpuHj3OZ/view?usp=sharing
Thank you!
For the count I added the decision making of the "D";
Count =
SUMX(
ADDCOLUMNS(
RawData,
"Count",
var Dep = RawData[Dep]
var res1 = COUNTROWS(
FILTER(
{RawData[ETD],RawData[ATD],RawData[ETA],RawData[ATA],RawData[Estimated Delivery],RawData[Actual Delivery]},
NOT ISBLANK([Value])
)
)
var res2 = COUNTROWS(
FILTER(
{RawData[ETA],RawData[ATA],RawData[Estimated Delivery],RawData[Actual Delivery]},
NOT ISBLANK([Value])
)
)
return if (LEFT(Dep, 1) = "D", res1, res2)
),
[Count]
)
I also followed your logic to go with the Counts measure:
Counts =
SUMX(
ADDCOLUMNS(
RawData,
"Count",
var Dep = RawData[Dep]
var res1 = COUNTROWS(
FILTER(
{RawData[ETD],RawData[ATD],RawData[ETA],RawData[ATA],RawData[Estimated Delivery],RawData[Actual Delivery]},
ISBLANK([Value])
)
)
var res2 = COUNTROWS(
FILTER(
{RawData[ETA],RawData[ATA],RawData[Estimated Delivery],RawData[Actual Delivery]},
ISBLANK([Value])
)
)
return if (LEFT(Dep, 1) = "D", res1, res2)
),
[Count]
)
Then I added the measure %
% = RawData[Count]/RawData[Total]
Result:
I do believe you would be better of using calculated columns but did not go their as you had choosen measures already.
IF I would have started from scratch, I would have gone with an unpivot table in power query what makes the coding more dynamic

How do I get the period difference for each item in the table in PowerBI desktop?

As seen below, I need to find the difference in quantities for each individual fruits with respect to the previous value. I have previously tried using in built Power BI functions like "PreviousDay()" but haven't found success yet.
You can create these below 2 Measure for your purpose-
Pervious_Quantity =
Var current_row_date = MIN(your_table_name[Date])
var previous_date =
CALCULATE(
MAX(your_table_name[Date]),
FILTER(
ALLEXCEPT(your_table_name, your_table_name[Fruit]),
your_table_name[Date] < current_row_date
)
)
RETURN
CALCULATE(
SUM(your_table_name[Quantity]),
FILTER(
ALLEXCEPT(your_table_name, your_table_name[Fruit]),
your_table_name[Date] = previous_date
)
)
Difference = min(your_table_name[Quantity]) - if([Pervious_Quantity] = BLANK(),0, [Pervious_Quantity])
Here is the final output-

Create column "after" in Powerbi (DAX)

I have the following information and I want to create the column "Later" From isProm : is the next day have the same value or no?
Date isProm Later
2018-06-06 1 1
2018-06-13 1 1
2018-08-20 1 1
2018-09-12 1 0
2018-09-12 0 0
Could you help me to do that with day please?
Thank you very much,
Ana
Create your new Custom Column with this below code-
Option 1:
later =
var current_row_isporm = your_table_name[isProm]
var current_row_date = your_table_name[Date]
var next_date =
CALCULATE(
MIN(your_table_name[Date]),
FILTER(
ALL(your_table_name),
your_table_name[Date] > current_row_date
)
)
var nex_date_isporm =
CALCULATE(
MIN(your_table_name[isProm]),
FILTER(
ALL(your_table_name),
your_table_name[Date] = next_date
)
)
RETURN IF(current_row_isporm = nex_date_isporm,1,0)
Option 2: You can also use this below code for same output-
later =
var current_row_isporm = your_table_name[isProm]
var current_row_date = your_table_name[Date]
var next_date_isporm =
CALCULATE(
MINX(
TOPN(
1,
FILTER(
ALL(your_table_name),
your_table_name[Date] > current_row_date
),
your_table_name[Date].[Date],ASC
),
your_table_name[isProm]
)
)
RETURN IF(current_row_isporm = next_date_isporm,1,0)
Here is the output. I have slightly different output because of date format in my laptop.