The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello Everyone,
I am new to Power BI, aplogies if this question already been asked
i have below requirement
i have date column and two measures
consider today is 03-06-2020
i need to create table by using date column as column header and measures are row headers like below
Current Date Previous Date Last Year Current Date Last Year Previous Date
03-06-2020 03-05-2020 03-06-2019 03-05-2019
Measure 1 123 345 345 555
Measure 2 234 345 321 223
Thanks in advance
@PowerBI @desktop
You could create a disconnected table. Then you measure could calculate differently based on the category. So, perhaps create a table like below using Enter Data query
Table: Categories
Category
Current Date
Previous Date
Last Year Current Date
Last Year Previous Date
Measure 1 =
VAR __Catetory = MAX('Categories'[Category])
SWITCH(__Category,
"Current Date",SUMX(FILTER('Table',[Date] = TODAY()),'Table'[Value]),
"Previous Date",SUMX(FILTER('Table',[Date] = (TODAY() -1) *1.),'Table'[Value]),
...
Make sure you have a date table.
Sales = CALCULATE(SUM(Sales[Sales Amount]),'Date'[Date])
yesterday Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Day))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
yesterday Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd(dateadd('Date'[Date],-1,Year),-1,Day))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
Thank you so much for very quick response,
I created date calender and joined with my date column, however when i used same calculation
for each date from date table i am getting same value, Please help me how i get value only for current date
Thanks & Regards
SV