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.
Hi!
I'm trying to add 1 day to a date because the data (for example) shows in January but I would like it to show in February. The case is: a contract ends at 1 date and the new contract starts at a new date. Problem is: when filtering to the data I would like to show, I can only get the ending date. In most cases this is at the end of the month, for example 31-01-2025, so in the report it obviously shows up in January. I would like it to show in February, that's why I would like to add 1 day. The date column is a integer '20250131'. So I need to convert it to date with DAX + I need filters to get the specific data out.
This is one of the things that I tried:
Contracts =
CALCULATE(
DISTINCTCOUNT('FACT_Contract'[%ContractKey]),
'FACT_Contract'[VALUE] = 1.00,
'FACT_Contract'[Subject] IN { "Days" },
DATE(
DIVIDE(SELECTEDVALUE('FACT_Contract'[DATE]), 10000),
DIVIDE(MOD(SELECTEDVALUE('FACT_Contract'[DATE]), 10000), 100),
MOD(SELECTEDVALUE('FACT_Contract'[DATE]), 100)
)
)
This is the error that I'm getting: "The True/False expression does not specify a column. Each True/False expressions used as a table filter expression must refer to exactly one column."
Converting the date in a single measure works, filtering the data to get what I need works in a single measure. But combining both doesn't work.
I'm not sure if it's even possible to do what I want. If anyone has an idea, please let me know.
Thanks in advance!
Solved! Go to Solution.
@Youri98 Convert the integer date to a date format and add one day:
DAX
ConvertedDate =
DATE(
DIVIDE(SELECTEDVALUE('FACT_Contract'[DATE]), 10000),
DIVIDE(MOD(SELECTEDVALUE('FACT_Contract'[DATE]), 10000), 100),
MOD(SELECTEDVALUE('FACT_Contract'[DATE]), 100)
) + 1
Use this new date in your calculations and filters:
DAX
Contracts =
CALCULATE(
DISTINCTCOUNT('FACT_Contract'[%ContractKey]),
'FACT_Contract'[VALUE] = 1.00,
'FACT_Contract'[Subject] IN { "Days" },
DATE(
DIVIDE(SELECTEDVALUE('FACT_Contract'[DATE]), 10000),
DIVIDE(MOD(SELECTEDVALUE('FACT_Contract'[DATE]), 10000), 100),
MOD(SELECTEDVALUE('FACT_Contract'[DATE]), 100)
) + 1
)
Proud to be a Super User! |
|
@Youri98 Convert the integer date to a date format and add one day:
DAX
ConvertedDate =
DATE(
DIVIDE(SELECTEDVALUE('FACT_Contract'[DATE]), 10000),
DIVIDE(MOD(SELECTEDVALUE('FACT_Contract'[DATE]), 10000), 100),
MOD(SELECTEDVALUE('FACT_Contract'[DATE]), 100)
) + 1
Use this new date in your calculations and filters:
DAX
Contracts =
CALCULATE(
DISTINCTCOUNT('FACT_Contract'[%ContractKey]),
'FACT_Contract'[VALUE] = 1.00,
'FACT_Contract'[Subject] IN { "Days" },
DATE(
DIVIDE(SELECTEDVALUE('FACT_Contract'[DATE]), 10000),
DIVIDE(MOD(SELECTEDVALUE('FACT_Contract'[DATE]), 10000), 100),
MOD(SELECTEDVALUE('FACT_Contract'[DATE]), 100)
) + 1
)
Proud to be a Super User! |
|
I accidently clicked 'Accept as solution' without trying so far. I need to replace the date stuff in the 2nd DAX with the ConvertedDate right?
User | Count |
---|---|
11 | |
8 | |
6 | |
6 | |
5 |
User | Count |
---|---|
24 | |
14 | |
13 | |
9 | |
7 |