KeepTrying
Active Member
- Joined
- Aug 19, 2012
- Messages
- 276
- Office Version
- 365
- 2010
- Platform
- Windows
Hi Guys,
I have an issue which seems to be easy but it's DAX so it isn't
I have similar Table (called "Data") as source:
Added Table to data model then inserted a Power Pivot: count values in column "C" per Date and per Country:
I started to get proper values for previous date but couldn't do it properly.
You can see that in Pivot between row 8 and 12: previous date values are correct only for 2022.04.19 and 2022.05.09 but incorrect for the rest:
My DAX formula for Power Pivot (between row 8 and 12):
=var currentcountry = IF(HASONEVALUE(Data[Country]),VALUES(Data[Country]),BLANK())
var currentdate = MAXX(
FILTER(ALL(Data),Data[ExtractDate]= MAX(Data[ExtractDate]) && Data[Country]=currentcountry),Data[ExtractDate])
var previousdate = MAXX(
FILTER(ALL(Data),Data[ExtractDate]<currentdate && Data[Country]=currentcountry),Data[ExtractDate])
return
CALCULATE([Count of Status_Groupped_measure],FILTER(ALL(Data[ExtractDate]),Data[ExtractDate]=previousdate), Data[Country]=currentcountry)
For DAX about you'll need "Count of Status_Groupped_measure":
=COUNT(Data[Status_Groupped])
I found that missing data is a problem: e.g. there is no value for HU for 2022.04.24 in source so cell is empty in Pivot. I assume these missing data in source table leads to incorrect values in Power Pivot (between row 8 and 12 on last picture) - but can't fix it.
Links I used:
Comparing with previous selected time period in DAX - SQLBI
Growth from Previous Non Consecutive Date - DAX Challenge - Goodly
Thanks for your advice/help in advance.
Kind Regards,
KeepTrying
I have an issue which seems to be easy but it's DAX so it isn't
I have similar Table (called "Data") as source:
Added Table to data model then inserted a Power Pivot: count values in column "C" per Date and per Country:
I started to get proper values for previous date but couldn't do it properly.
You can see that in Pivot between row 8 and 12: previous date values are correct only for 2022.04.19 and 2022.05.09 but incorrect for the rest:
My DAX formula for Power Pivot (between row 8 and 12):
=var currentcountry = IF(HASONEVALUE(Data[Country]),VALUES(Data[Country]),BLANK())
var currentdate = MAXX(
FILTER(ALL(Data),Data[ExtractDate]= MAX(Data[ExtractDate]) && Data[Country]=currentcountry),Data[ExtractDate])
var previousdate = MAXX(
FILTER(ALL(Data),Data[ExtractDate]<currentdate && Data[Country]=currentcountry),Data[ExtractDate])
return
CALCULATE([Count of Status_Groupped_measure],FILTER(ALL(Data[ExtractDate]),Data[ExtractDate]=previousdate), Data[Country]=currentcountry)
For DAX about you'll need "Count of Status_Groupped_measure":
=COUNT(Data[Status_Groupped])
I found that missing data is a problem: e.g. there is no value for HU for 2022.04.24 in source so cell is empty in Pivot. I assume these missing data in source table leads to incorrect values in Power Pivot (between row 8 and 12 on last picture) - but can't fix it.
Links I used:
Comparing with previous selected time period in DAX - SQLBI
Growth from Previous Non Consecutive Date - DAX Challenge - Goodly
Thanks for your advice/help in advance.
Kind Regards,
KeepTrying