grand total empty in table - powerbi

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.

Related

Trying to get list of Venues with respect to Suppliers

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

How to get the Top N vales based on a column for each category in PowerBI?

I am facing the issue while filtering out the data based on a "Date" column to fetch top 3 for each category. Below is the sample data:
Can anybody help me with this to get the below-expected output?
You can try this (here dummy data); You can choice ASC or DESC based on your need:
Ranking by Date = var _cat = SELECTEDVALUE( Sheet1[Category])
return
IF(RANKX(FILTER(ALL(Sheet1), Sheet1[Category]= _cat), calculate(MAX(Sheet1[Date])),,ASC ,Skip)<=2, 1,BLANK())
or by Sale:
Ranking by Sales =
IF (
ISINSCOPE ('Sheet1'[Date] ),
VAR ProductsToRank = 2
VAR SalesAmount = [SumOf]
RETURN
IF (
SalesAmount > 0,
VAR VisibleProducts =
CALCULATETABLE (
VALUES ( 'Sheet1' ),
ALLSELECTED ( 'Sheet1'[Date] )
)
VAR Ranking =
RANKX (
VisibleProducts,
[SumOf],
SalesAmount
)
RETURN
IF (
Ranking > 0 && Ranking <= ProductsToRank,
1
)
)
)
Or you can create a new table in DAX like this:
Top2 = GENERATE(VALUES(Sheet1[Category]), TOPN(2, FILTER(SELECTCOLUMNS(ALL(Sheet1[Category], Sheet1[Date]),"Cat",[Category],"Date",[Date]),[Cat] = [Category]),[Date]))

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.

How to calculate Dynamic Moving Average without any date reference?

I am looking for some clarification with regards to moving average calculation. My data looks like the screenshot attached.
I checked online for suggestion but it went awry. Most of the moving averages work with date (in date format). As I am having Day...only in numeric format...I am not sure which function would help me to get Mov_Avg for 3 Day time frame on the Increment col. My desired output should be col 3_day_Avg
You can use your column Increase (created using Power Query) and create this below measure for your required output-
last_three_day_average =
VAR current_row_day = MIN(your_source_table_name[day])
VAR current_row_country = MIN(your_source_table_name[country])
VAR current_row_case_death = MIN(your_source_table_name[cases/death])
VAR current_row_count = MIN(your_source_table_name[count])
RETURN
CALCULATE(
AVERAGE(your_source_table_name[increase]),
FILTER(
ALL(your_source_table_name),
your_source_table_name[country] = current_row_country
&& your_source_table_name[cases/death] = current_row_case_death
&& your_source_table_name[day] <= current_row_day
&& your_source_table_name[day] >= current_row_day - 2
)
)
Here is the final output-
Alternatively, if you wants not to use Power Query, You can use Custom column and that case you have to convert your Measure increase_using_measure as a column. As aggregation is required, you can not refer a measure for that. Here below is the code for column-
increase_using_column =
VAR current_row_day = your_source_table_name[day]
VAR current_row_country = your_source_table_name[country]
VAR current_row_case_death = your_source_table_name[cases/death]
VAR current_row_count = your_source_table_name[count]
VAR previous_day_count =
LOOKUPVALUE(
your_source_table_name[count],
your_source_table_name[day],current_row_day-1,
your_source_table_name[country],current_row_country,
your_source_table_name[cases/death],current_row_case_death
)
RETURN if(previous_day_count = BLANK(),current_row_count, current_row_count - previous_day_count)
Now you can use the above column created using DAX in your Last 3 days average calculation as below-
last_three_day_average =
VAR current_row_day = MIN(your_source_table_name[day])
VAR current_row_country = MIN(your_source_table_name[country])
VAR current_row_case_death = MIN(your_source_table_name[cases/death])
VAR current_row_count = MIN(your_source_table_name[count])
RETURN
CALCULATE(
AVERAGE(your_source_table_name[increase_using_column]),
FILTER(
ALL(your_source_table_name),
your_source_table_name[country] = current_row_country
&& your_source_table_name[cases/death] = current_row_case_death
&& your_source_table_name[day] <= current_row_day
&& your_source_table_name[day] >= current_row_day - 2
)
)
Output will be same as shown above.